Location: PHPKode > projects > SchoolMate > schoolmate/DeficiencyReport.php
 <h1>Deficiency Report</h1>
 <table align='center' width='400' cellspacing='0' cellpadding='0' border='0'>
 <form name='classes' action='./index.php' method='POST'>

 <table border='0' width='400'>
 <b>Semester: </b> <select name='semester' onChange='document.classes.submit();'>
  // Get a list of semesters //
  $query = mysql_query("SELECT semesterid, title FROM semesters ORDER BY startdate DESC")
	or die("ViewCourses.php: Unable to get a list of semesters for drop-down - ".mysql_error());

	$q = mysql_query("SELECT semesterid FROM semesters WHERE startdate < CURDATE() < enddate");
	$temp = mysql_fetch_row($q);
	$_POST['semester'] = $temp[0];

  while($semester = mysql_fetch_row($query))
   print("<option value='$semester[0]' ".( $_POST['semester']==$semester[0]&&$_POST['semester']!=NULL ? "SELECTED" : "").">$semester[1]</option>");

   <option value='-1' ".($_POST['semester']==-1 ? "SELECTED" : "").">All</option>

  <table cellspacing='0' width='400' class='dynamiclist'>
  <tr class='header' align='left'>
   <th style='padding-left: 10px;'>Student</th>

 // Get the list of defficient students //
 $query = mysql_query("SELECT studentid, courseid FROM registrations ORDER BY courseid")
   or die("DeficiencyReport: Unable to get a list of deficient students - ".mysql_error());

 while($deficient = mysql_fetch_row($query))
  // Make sure we're in the right semester //
  $q = mysql_query("SELECT semesterid FROM courses WHERE courseid = $deficient[1]");
  $semesterid = mysql_fetch_row($q);

  // If dispalying all semesters, make sure $semesterid always equals $_POST['semester'] //

  if($semesterid[0] != $_POST['semester'])

  $q = mysql_query("SELECT fname,lname FROM students WHERE studentid = $deficient[0]");
  $student = mysql_fetch_row($q);

  $q = mysql_query("SELECT coursename, totalpoints, cperc FROM courses WHERE courseid = $deficient[1]");
  $class = mysql_fetch_row($q);

  $q = mysql_query("SELECT currentpoints FROM registrations WHERE studentid = $deficient[0] AND courseid = $deficient[1]");
  $currentpoints = mysql_fetch_row($q);

  if($class[1] >  0)
   $percentage = number_format($currentpoints[0]/$class[1],2);
   $percentage = "0.00";

  $percentage *= 100;

  if($percentage >= $class[2] )
  print("<tr class='".( $row%2==0 ? "even" : "odd" )."'>
   <td align='left' style='padding-left: 10px;'>$student[0] $student[1]</td>
   <td align='left'>$class[0]</td>
   <td align='left'>$percentage&#37;</td>

print("  </table>
  <br />
  <input type='button' value=' Back ' onClick='document.classes.page2.value=2;document.classes.submit();'>
  <input type='hidden' name='page2' value='$page2'>
  <input type='hidden' name='logout'>
  <input type='hidden' name='page' value='$page'>
 <table width='520' border=0 cellspacing=0 cellpadding=0 height=1>
   <td valign='top'>
Return current item: SchoolMate