Jump to content

heshan

Members
  • Posts

    170
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

heshan's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  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"; } } ?>
×
×
  • 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.