Location: PHPKode > projects > phpLabMan > attendance/report.php
<?php require_once('config.php'); ?>

	
<html>
<head>
</head>
<body>

	<?
	$ClassID = $_REQUEST[ClassID];
	$StartTime = $_REQUEST[StartDate] . " 00:00:00";
	$EndTime = $_REQUEST[EndDate] . " 00:00:00";
	$StudentID = $_REQUEST[StudentID];
	
	if(empty($ClassID)){
	

	
	mysql_select_db($database_attendance, $attendance);
	$query_Recordset1 = "SELECT * FROM swipes ORDER BY Time";
	//echo $query_Recordset1;
	$Recordset1 = mysql_query($query_Recordset1, $attendance) or die(mysql_error());
	$row_Recordset1 = mysql_fetch_assoc($Recordset1);
	$totalRows_Recordset1 = mysql_num_rows($Recordset1);
	


	do {
		
		$ThisTime = substr($row_Recordset1['Time'], 0, 10);
		//COMPARE
		
		if ($ThisTime != $LastTime) {
			if($WriteClassFlag){
				echo " <a href=\"report.php?ClassID=1&StartDate=$LastTime&EndDate=$ThisTime\">MUS101</a> | <a href=\"report.php?ClassID=2&StartDate=$LastTime&EndDate=$ThisTime\">MUS109</a> | <a href=\"report.php?ClassID=3&StartDate=$LastTime&EndDate=$ThisTime\">CFA100</a> | <a href=\"report.php?ClassID=All&StartDate=$LastTime&EndDate=$ThisTime\">ALL</a><br \>";
				$WriteClassFlag = false;
			}
			echo  $ThisTime ;
			$WriteClassFlag = true;
		}
		$LastTime = $ThisTime;
		
		if($LastTime == $ThisTime){
		$ThisTime = gmdate("Y-m-d");
		}
		
	  } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
	  
	  echo " <a href=\"report.php?ClassID=1&StartDate=$LastTime&EndDate=$ThisTime\">MUS101</a> | <a href=\"report.php?ClassID=2&StartDate=$LastTime&EndDate=$ThisTime\">MUS109</a> | <a href=\"report.php?ClassID=3&StartDate=$LastTime&EndDate=$ThisTime\">CFA100</a> | <a href=\"report.php?ClassID=All&StartDate=$LastTime&EndDate=$ThisTime\">ALL</a><br \>";
	  
	?>
	
	<form action='report.php'>
	<input type='hidden' name='ClassID' value='All'>
	Search by Student ID: <input size='6' type='textbox' name='StudentID'><input type='submit' value='Search'>
	</form>
	
	<?
			
	
	mysql_free_result($Recordset1);
	

	} else {
	

	
	mysql_select_db($database_attendance, $attendance);
	
	if($ClassID=='All'){
		if(empty($StudentID)){
		$query_Recordset2 = "SELECT * FROM swipes WHERE Time >= '$StartTime' AND Time <= '$EndTime' ORDER BY swipes.StudentID";
		} else {
		$query_Recordset2 = "SELECT * FROM swipes WHERE StudentID = $StudentID";
		
		$query_Recordset3 = "SELECT * FROM students WHERE StudentID = $StudentID";
		$Recordset3 = mysql_query($query_Recordset3, $attendance) or die(mysql_error());
		$row_Recordset3 = mysql_fetch_assoc($Recordset3);
		$totalRows_Recordset3 = mysql_num_rows($Recordset3);
		
		
		}
	} else {
		$query_Recordset2 = "SELECT * FROM swipes JOIN student_class ON student_class.studentID = swipes.StudentID JOIN students ON students.studentID = swipes.StudentID WHERE student_class.ClassID = $ClassID AND Time >= '$StartTime' AND Time <= '$EndTime' ORDER BY swipes.StudentID";
	}
	
	
	//echo $query_Recordset2;
	$Recordset2 = mysql_query($query_Recordset2, $attendance) or die(mysql_error());
	$row_Recordset2 = mysql_fetch_assoc($Recordset2);
	$totalRows_Recordset2 = mysql_num_rows($Recordset2);
	
	
	
	do {
	
	$StudentName = $row_Recordset2['LastName'] . ", " . $row_Recordset2['FirstName'];

	if(empty($StudentName)){
	$StudentName = $row_Recordset3['LastName'] . ", " . $row_Recordset3['FirstName'];
	}
		if($row_Recordset2['StudentID']== $LastStudentID){
			 $InOutCount++;
			} else {
			if($InOutCount>0 && $InOutCount<2){
			 echo "<b style='color:red'>$LastStudentName - Missing Swipe</b><br \>";
			}
		 	$InOutCount=1;
		}
		if($row_Recordset2['Time'] < "2006-03-26 13:50:00"){
		echo "$StudentName - " . $row_Recordset2['StudentID'] . " - " . $row_Recordset2['Time'] . "<br \>";
	    } else {
	    echo "<a href='images/" . $row_Recordset2['Image'] . "'>$StudentName - " . $row_Recordset2['StudentID'] . " - " . $row_Recordset2['Time'] . "</a><br \>";
	    }
	    
	    $LastStudentID = $row_Recordset2['StudentID'];
	    $LastStudentName = $StudentName;
	    
	  } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
	
	mysql_free_result($Recordset2);
	//mysql_free_result($Recordset2);


}

 ?>
Return current item: phpLabMan