I want to create an attendance system using PHP MySQL and even a little jQuery. The specification I have in mind is to have all my members echoed in one table row and in the rest I would like to have an infinite array of dates but showing month by month.
I just wanted to know how I could get the days of the month into this table dynamically? Does anyone have any working examples or point me into the right direction?
I have a mini layout which goes like so or view my jsFiddle:
<form action='this_page.php' method='post'>
<table>
<th>Member</th>
<th>Day One</th>
<th>Day Two</th>
<tr>
<td>Memeber One</td>
<td><input type='checkbox' name='student[davidsmith]' value='1' /></td>
<td><input type='checkbox' name='student[davidsmith]' value='1' /></td>
</tr>
<tr>
<td>Member Two</td>
<td><input type='checkbox' name='student[davidsmith]' value='1' /></td>
<td><input type='checkbox' name='student[davidsmith]' value='1' /></td>
</tr>
</table>
</form>
Not 100% sure what you want, but to get the days of a month, you can use PHP's DateTime
e.g.
$startDate = new DateTime(); //today
$endDate = new DateTime('2013-12-31');
for ($c = $startDate; $c <= $endDate; $c->modify('+1 day')) {
echo $c->format('d');
}
will print the days from today to the rest of the year, use ->format('N') to get the month name. check here for other params accepted by format()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With