I have a table attendance which contains id(int), attendance(char), and date(date datatype) columns. Values get stored in this table through a php file. In the below code I have given two textbox for the user to select date range. eg. from 2012-10-15 to 2012-10-17.. when the user selects date range I am populating the whole class students attendance. So in my html table im populating name, roll no, attendance and date. But I do not know how to populate the date in different columns. suppose the user selects 15th october to 17th october as mentioned above, the attendance for these three dates should appear. I have tried something but I guess it's wrong.
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
dateFormat: "yy-mm-dd",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
dateFormat: "yy-mm-dd",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
</script>
<?php
$report = mysql_query("SELECT id, studname, studroll, attendance, date FROM student a, samp b WHERE a.id = b.stud_id AND b.date BETWEEN '".$_POST['from']."' AND '".$_POST['to']."'") or die(mysql_error());
echo '<form action="" method="post">
Please select date :<input name="from" id="from" type="text" />
Please select date :<input name="to" id="to" type="text" />
<table width="600" border="2">
<tr>
<th width="83" scope="col">ID</th>
<th width="83" scope="col">Student Name</th>
<th width="55" scope="col">Student Roll.No</th>
<th width="51" scope="col">Attendance</th>
</tr>';
while(list($id, $studname, $studroll, $attendance, $date) = mysql_fetch_row($report))
{
echo '<tr>
<td>'.$id.'</td>
<td>'.$studname.'</td>
<td>'.$studroll.'</td>
<td>'.$date.'</td>
</tr>';
}
echo '</table><input type="submit" name ="submit" id="submit2" value ="submit"></input>
</form>';
?>
Student is my master table from which Iam fetching student name, student rollno.. and from table samp, iam fetching attendance and the date on which attendance was taken.. Is there any mistake in my table design. Kindly guide..