Jump to content

heshan

Members
  • Posts

    170
  • Joined

  • Last visited

Everything posted by heshan

  1. Hi all, I want to enter student marks to a form and i want to make sure the marks should be inserted to all the subjects, they are positive and should be within (0-100) range. Therefore i have created following validation.. Validations were successfully displayed..But the problem is whenever a validation say "insert values" displayes and then click on ok button suddenly the page redirects to the next page without allowing other fields to be filled..Can anyone tell me how can i avoid this problem??? <script type="text/javascript"> function checkForm(frm) { var id = frm.getElementsByTagName("input"); for (var i = 0; i < id.length-1; i++) { if (id[i].value == "") { alert("Please insert value"); id[i].focus(); return false; } if (id[i].value.match(/\D+/)) { alert("Please input positive integers only"); return false; } if(parseInt(id[i].value) > 100) { alert("Please input value less than 100"); id[i].focus(); return false; } } frm.submit(); return true; } </script> ---------------------------------------------------------------------------- <td><input type="submit" name="Submit" id="button" value="Save" onclick="checkForm(this.form);" /></td>
  2. Thanks guys..Yeah i missed '$name' instead of '$name_with_initials' in two locations.Now i have corrected it and works fine..:-) @psycho; Thanks for your recommendations also..Highly appreciated them..
  3. @nodirtyrockstar; No i didn't want that kind of thing...In my database table there is a seperate field called "name_with_initial". For an understanding perspective let's say it is a full name.. I want that name to be displayed as a result. But the problem here is only first string of that letter is displayed instead of retrieving full string of letters. Ex : Let's say full name is "kevin Barber". But it displayed in the name column field as "k" only..
  4. Hi all, I want to view the records of a particular student. (Admission Number, Name With Initials and Marks) These data display after filling a user form..I have one issue. That is the Name With Initials of the student is displayed partially..(only one letter) Ex : If the name is 'Keith' then only 'k' is displayed..What will be the issue?? Here is my coding.. <form id="form1" name="form1" method="post" action=""> <?php $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); $grade=$_GET["grade"]; $class=$_GET["class"]; $stream=$_GET["stream"]; $subject=$_GET["subject"]; $term=$_GET["term"]; $year=$_GET["year"]; ?> <table>------- <tr> <td width="17"> </td> <td width="17"> </td> <td>Subject </td> <td colspan="2"><?php $query="select name from subject where subject_id='$subject'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $name=$row['name']; } echo $name; ?> </td> <td colspan="2"> </td> <td width="184"> </td> </tr> <tr> <td> </td> <td> </td> <td width="94"><label>Term</label> </td> <td colspan="2"><?php echo $term; ?></td> <td colspan="2"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td><label>Grade</label> </td> <td width="74"><?php echo $grade; ?></td> <td width="82"><label><label>Class</label> </label></td> <td width="78"><?php echo $class; ?></td> <td width="67"><label>Stream</label> </td> <td><?php echo $stream; ?></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td colspan="2"> </td> <td colspan="2"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <?php if($stream!=null){ $query="SELECT class_id FROM class WHERE class.grade_id='$grade' AND class.class_name='$class' AND class.stream='$stream'"; }else{ $query="SELECT class_id FROM class WHERE class.grade_id='$grade' AND class.class_name='$class'"; } $result=mysql_query($query) or die (mysql_error()); while($row=mysql_fetch_array($result)){ $class_id=$row['class_id']; } $query="SELECT exam_id FROM exam WHERE exam_name='$term' AND class_id='$class_id' AND year='$year'"; $result=mysql_query($query) or die (mysql_error()); while($row=mysql_fetch_array($result)){ $exam_id=$row['exam_id']; } $query="SELECT admission_no,mark FROM mark WHERE subject_id='$subject' AND exam_id='$exam_id'"; $result=mysql_query($query) or die (mysql_error()); $i=0; while($row=mysql_fetch_array($result)){ $i++; $admission_no[$i]=$row['admission_no']; $mark[$i]=$row['mark'];} for($j=1;$j<=$i;$j++){ $query1="SELECT name_with_initial FROM student_info WHERE admission_no='".$admission_no[$j]."'"; $result1=mysql_query($query1) or die (mysql_error()); while($row1=mysql_fetch_array($result1)){ $name[$j]=$row1['name_with_initial']; } } ?> <td colspan="6"><table width="444" border="1"> <tr> <td width="98" align="center"><label>Admission No</label> </td> <td width="205" align="center"><label>Name</label> </td> <td width="119" align="center"><label>Mark</label> </td> </tr> <?php for($y=1;$y<=$i;$y++) { echo "<tr>"; echo"<td>".$admission_no[$y]."</td>"; echo "<td>".$name[$y]."</td>"; echo "<td>".$mark[$y]."</td>"; echo "</tr>"; } ?> </table> </form>
  5. Hi all, There was a white space in my Term drop down list. That's the problem..Now i fixed it and works properly...... Thanks all of you guyz who helped me out..thanks again..
  6. In my JOIN query i removed following part in the last line..Thereafter When i select an admission number and term (term1, 2 or 3) relevant results were displayed. But it does not take account the 'term'..It means irrespective of the term (1, 2 or 3) marks were displayed relevant to that particular admission number.
  7. Yeah..I have run it in my PHP myAdmin..An empty result set was found... @ Jessica;Here is the coding.. <?php require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { public function myconnection(){ $this->con = mysql_connect("localhost","root",""); mysql_select_db("student_management", $this->con); $admission_no=$_POST['admission_no']; $term = $_POST['term']; $sql="SELECT mark.admission_no, student_info.name_with_initial,subject.name, exam.exam_name, mark.mark FROM mark INNER JOIN subject ON mark.subject_id=subject.subject_id INNER JOIN exam ON mark.exam_id=exam.exam_id INNER JOIN student_info ON mark.admission_no=student_info.admission_no WHERE mark.admission_no='$admission_no' AND exam.exam_name='$term'"; $this->result=mysql_query($sql) or die (mysql_error()); } // Colored table public function ColoredTable($header,$data) { // Colors, line width and bold font $this->SetFillColor(255, 128, 0); $this->SetTextColor(255); $this->SetDrawColor(128, 0, 0); $this->SetLineWidth(0.3); $this->SetFont('', 'B'); // Header $w = array(25, 40, 20, 20, 20); $num_headers = count($header); for($i = 0; $i < $num_headers; ++$i) { $this->Cell($w[$i], 4, $header[$i], 1, 0, 'C', 1); } $this->Ln(); // Color and font restoration $this->SetFillColor(255, 255, 255); $this->SetTextColor(0); $this->SetFont(''); // Data $fill = 0; while($row2 = mysql_fetch_array($this->result)) { $this->Cell($w[0], 6, $row2['admission_no'], 'LR', 0, 'L', $fill); $this->Cell($w[1], 6, $row2['name_with_initial'], 'LR', 0, 'L', $fill); $this->Cell($w[2], 6, $row2['name'], 'LR', 0, 'L', $fill); $this->Cell($w[3], 6, $row2['exam_name'], 'LR', 0, 'L', $fill); $this->Cell($w[4], 6, $row2['mark'], 'LR', 0, 'L', $fill); $this->Ln(); $fill=!$fill; } $this->Cell(array_sum($w), 0, '', 'T'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Maliyadeva Balika Vidyalaya'); $pdf->SetTitle('Student Mark Sheet'); $pdf->SetSubject(''); $pdf->SetKeywords(''); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 011', PDF_HEADER_STRING); // set header and footer fonts //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('times', 'BI', 7); // add a page $pdf->AddPage(); // set some text to print $txt = <<<EOD Maliyadeva Balika Vidyalaya, Colombo Road, Kurunegala. Tel:037 2222372 Student Mark Sheet EOD; // print a block of text using Write() $pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0); //Column titles $header = array('Admission Number', 'Name With Initials', 'Subject', 'Term', 'Mark' ); //Data loading //$data = $pdf->LoadData($data2); $pdf->myconnection(); // print colored table $pdf->ColoredTable($header, ""); // --------------------------------------------------------- //Close and output PDF document //$pdf->Output('Customer Information.pdf', 'I'); die(); mysql_close($con); ?>
  8. Hi Jessica, It resulted an empty page..It means data is not coming to the page...
  9. Thanks Barand..I think it is ok..But why data is not coming...Is it due to a problem in my table structure?? SELECT mark.admission_no, student_info.name_with_initial,subject.name, exam.exam_name, mark.mark FROM mark INNER JOIN subject ON mark.subject_id=subject.subject_id INNER JOIN exam ON mark.exam_id=exam.exam_id INNER JOIN student_info ON mark.admission_no=student_info.admission_no WHERE mark.admission_no='2012/1' AND exam.exam_name='Term 2'TCPDF ERROR: Some data has already been output, can't send PDF file
  10. Hi DarkerAngel, Thanks for your points..I have tried this print_r($array) thing also..But there is not any output.It means i think the data should not be retrieved properly..Here is my full page. <?php require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { public function myconnection(){ $this->con = mysql_connect("localhost","root",""); mysql_select_db("student_management", $this->con); $admission_no=$_POST['admission_no']; $term = $_POST['term']; $this->result = mysql_query("SELECT mark.admission_no, student_info.name_with_initial,subject.name, exam.exam_name, mark.mark FROM mark INNER JOIN subject ON mark.subject_id=subject.subject_id INNER JOIN exam ON mark.exam_id=exam.exam_id INNER JOIN student_info ON mark.admission_no=student_info.admission_no WHERE mark.admission_no='$admission_no' AND exam.exam_name='$term'") or die (mysql_error()); $array=mysql_fetch_assoc($this->result); print_r($array); } // Colored table public function ColoredTable($header,$data) { // Colors, line width and bold font $this->SetFillColor(255, 128, 0); $this->SetTextColor(255); $this->SetDrawColor(128, 0, 0); $this->SetLineWidth(0.3); $this->SetFont('', 'B'); // Header $w = array(25, 40, 20, 20, 20); $num_headers = count($header); for($i = 0; $i < $num_headers; ++$i) { $this->Cell($w[$i], 4, $header[$i], 1, 0, 'C', 1); } $this->Ln(); // Color and font restoration $this->SetFillColor(255, 255, 255); $this->SetTextColor(0); $this->SetFont(''); // Data $fill = 0; while($row2 = mysql_fetch_array($this->result)) { $this->Cell($w[0], 6, $row2['admission_no'], 'LR', 0, 'L', $fill); $this->Cell($w[1], 6, $row2['name_with_initial'], 'LR', 0, 'L', $fill); $this->Cell($w[2], 6, $row2['name'], 'LR', 0, 'L', $fill); $this->Cell($w[3], 6, $row2['exam_name'], 'LR', 0, 'L', $fill); $this->Cell($w[4], 6, $row2['mark'], 'LR', 0, 'L', $fill); $this->Ln(); $fill=!$fill; } $this->Cell(array_sum($w), 0, '', 'T'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Maliyadeva Balika Vidyalaya'); $pdf->SetTitle('Student Mark Sheet'); $pdf->SetSubject(''); $pdf->SetKeywords(''); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 011', PDF_HEADER_STRING); // set header and footer fonts //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('times', 'BI', 7); // add a page $pdf->AddPage(); // set some text to print $txt = <<<EOD Maliyadeva Balika Vidyalaya, Colombo Road, Kurunegala. Tel:037 2222372 Student Mark Sheet EOD; // print a block of text using Write() $pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0); //Column titles $header = array('Admission Number', 'Name With Initials', 'Subject', 'Term', 'Mark' ); //Data loading //$data = $pdf->LoadData($data2); $pdf->myconnection(); // print colored table $pdf->ColoredTable($header, ""); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('Customer Information.pdf', 'I'); mysql_close($con); ?>
  11. Hi Barand, I am generating reports in PHP by using TCPDF tool. There the report automatically comes provided that my query is accurate. We only need to change the SQL query in order to get the desired results. Here it displays columns in a atable format without any data. It means there is something wrong in my query..
  12. Hi All, I have a basic HTML form which accepts admission number and term values. Thereafter user should select 'Generate' button to view the results. I want these columns to be get displayed as results columns. Admission Number, Name with initials, Subject, Term and Mark. These data should be generated from following tables. exam (exam_id, exam_name,__) mark (mark_id, admission_no, subject_id, exam_id, mark) student_info (name_with_initial,____) subject (subject_id, name,___) I have created following query to output the above results. But the page does not generate any output.. //Pass the form data $admission_no=$_POST['admission_no']; $term = $_POST['term']; //query $this->result = mysql_query("SELECT mark.admission_no, student_info.name_with_initial,subject.name, exam.exam_name, mark.mark FROM mark INNER JOIN subject ON mark.subject_id=subject.subject_id INNER JOIN exam ON mark.exam_id=exam.exam_id INNER JOIN student_info ON mark.admission_no=student_info.admission_no WHERE mark.admission_no='$admission_no' AND exam.exam_name='$term'") or die (mysql_error());
  13. Actually not..i have very little understanding..Could you please help me??
  14. I have used this one..But it didn't work either..No output. <?php if (isset($_POST)){ $admission_no=$_POST["admission_no"]; if (!$admission_no){ $msg = "Invalid id"; print_r($admission_no); } ?>
  15. I have tried this one..But nothing happens. <?php if ($_POST){ $admission_no=$_POST["admission_no"]; if (!$admission_no){ $msg = "An invalid number"; } } ?>
  16. I want something like this to be done as a validation. In my form there 3 fields. Admission Number, Year and Term. If an user enters an admission number which is not exist in my database table a proper validation should display as "Invalid admission number". How this can be done? I have already validated marks added. <?php $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); $admission_no=$_POST["admission_no"]; $term=$_POST["term"]; $year=$_POST["year"]; //validate $query="SELECT COUNT(*) FROM mark INNER JOIN exam ON mark.exam_id=exam.exam_id WHERE mark.admission_no='$admission_no' AND exam.exam_name='$term' AND exam.year='$year'"; $result=mysql_query($query); $row=mysql_fetch_array($result); if($row[0]==0) { header("location:addStudentMarkForm.php?admission_no=".$admission_no."&term=".$term."&year=".$year); exit(); }else{ ?> <?php echo "For this admission number ".$admission_no." tream".$term." marks has been already Added."; echo "<BR><BR><BR>"; echo "<a href='addStudentMark.php'>Go to Add student mark page.</a>"; exit(); } } ?>
  17. Hi All, I have a student form which is used to select grade, class, stream and payment status from drop down lists. Thereafter it can be used to generate reports which are useful when finding students who are paid student fees and who are not paid fees. The 'stream' field ONLY uses when the user selects grade 12 or 13. Otherwise it should be disabled. How this can be achieved using javascript and PHP?? I have tried something like this. But it is not working... if(grade >=1 && grade<= 11): echo " disabled"; endif; ?>> <tr> <td> </td> <td width="117" align="center"><label>Grade</label> </td> <td width="69"><label> <select name="grade" id="select2"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> </select> </label></td> <td width="1" align="center"> </td> <td align="center"><label>Class</label> </td> <td width="71"><label> <select name="class" id="select3"> <option>A</option> <option>B</option> <option>C</option> <option>D</option> <option>E</option> <option>F</option> </select> </label></td> <td width="69" align="center"><label>Stream</label> </td> <td><select name="stream" id="jumpMenu3" <?php if(grade >=1 && grade<= 11): echo " disabled"; endif; ?>> <option>Maths</option> <option>Science</option> <option>Commerce</option> <option>Art</option> </select></td> </tr> <tr> <td colspan="2">Payment Status</td> <td colspan="2"><label> <select name="payment_status" id="select"> <option value="Y">Paid</option> <option value="N">Not Paid</option> </select> </label></td> <td> </td> <td colspan="2"> </td> <td> </td> </tr> <tr>
  18. Hi All, I want to generate time table reports. A form includes labels to enter grade, class and stream. After selecting data user should click on "Generate" button and relevant time table details. The data is submitted for the following page and there was an empty set of data shown in the report. I want to know where i went wrong? The piece of PHP code is as follows. table structure is as follows. class (class_id, class_name, grade_id, stream) subject (subject_id, name, --) time_table (class_id, time_from, time_to, subject_id, date) <?php public function myconnection(){ $this->con = mysql_connect("localhost","root",""); mysql_select_db("student_management", $this->con); $grade=$_POST['grade_ID']; $class=$_POST['class_ID']; $stream=$_POST['stream_ID']; $this->result = mysql_query("SELECT time_table.time_from, time_table.time_to, time_table.date, subject.name FROM time_table INNER JOIN subject ON time_table.subject_id=subject.subject_id INNER JOIN class ON time_table.class_id=class.class_id WHERE class.class_name='$class' AND class.stream='$stream'") or die (mysql_error()); } ?>
  19. Ohh yes..i found it..it says it does not specifically say which 'admission_no' to use. Therefore i changed it and now ok..Thanks everyone who helped me to solve this thread..
  20. Yeah, exactly..I removed them and run the query..It works perfectly.. But small issue. I want to display details relevant to that particular admission number ONLY. But it displays almost every record in the attendance table. I have inserted a WHERE clause at the end of the line. But it says "Column 'admission_no' in where clause is ambiguous" SELECT attendance_state.state, attendance.admission_no, attendance.date, student_info.name_with_initial FROM attendance_state INNER JOIN attendance ON attendance_state.state_id=attendance.state_id INNER JOIN student_info ON attendance.admission_no=student_info.admission_no WHERE admission_no='$admission_no'")
  21. I have created this one based on you'll comemnts..But still not working. SELECT attendance.admission_no, attendance.date, attendance_state.state, student_info.name_with_initial FROM attendance a1 INNER JOIN attendance_state a2 ON a1.state_id=a2.state_id INNER JOIN student_info a3 ON a1.admission_no=a3.admission_no
  22. Hi All, I want something like this to be done. When a user enters the admission number and click on "Generate" button the details of the relevant student should come. I want Student Name, Date and state to be displayed. But these fields are in 3 different tables. Therefore i want to join 3 tables. Can anyone help me regarding below query?? The table structure is as follows. attendance (admission_no, state_id, date) attendance_state (state_id, state) student_info (admission_no, name_with_initial,_____) "SELECT * FROM attendance a1 INNER JOIN attendance_state a2, student_info.name_with_initial a3 ON a1.state_id=a2.state_id WHERE a1.admission_no=a3.admission_no"
  23. ohh yes exactly..thanks Barand.. Now it fixed and working...
  24. That query executed successfully...Following is the result.. Table Create Table attendance_state CREATE TABLE `attendance_state` ( `state_id` int(20) NOT NULL AUTO_INCREMENT, ` state` varchar(50) NOT NULL, KEY `state_id` (`state_id`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1
  25. Hi All, I have a small problem related to a specific query. It creates following error. Unknown column 'attendance_state.state' in 'field list' $query="SELECT attendance_state.state,attendance_state.state_id from attendance_state inner join attendance on attendance_state.state_id=attendance.state_id where attendance.admission_no='".$admission_id[$i]."' and attendance.date='$date'"; $result=mysql_query($query) or die (mysql_error()); The table related to the query looks like this. "state_id" is set as auto increment field. attendance_state (state_id, state) attendance (admission_no, state_id, date)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.