I have a for loop that displays all the days in a month. I also have a table that has various dates stored in it. I want to be able to query that table to select total count of all records of each date in that month and display it on each date in the results of the for loop.
Don't know how to get it done.
I think the problem is in the query construction but i can't figure out the best way to go about it to achieve the aim.
For example, for day one of month June, i want to see 5 slots. for day two, 10 slots, etc
$ucimslots = "25";
$curyear = date("Y");
$month = $_POST['month'];
$day = date('j');
$daysinmonth = date('t',mktime(0,0,0,$month,1,$curyear));
$query = "SELECT uciID, bookingdate, paymentstatus FROM ucibooking WHERE bookingdate=?";
$stmt = $connQlife->prepare($query);
$stmt->bind_param('s', $day);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($uciID, $bookingdate, $paymentstatus);
$stmt->fetch();
$totalnumrows = $stmt->num_rows;
$stmt->close();
if ($totalnumrows!=0){
$availableslots = $ucimslots - $totalnumrows;
}else if ($totalnumrows==0){
$availableslots = $ucimslots;
}
<?Php for($day = 1; $day <= $daysinmonth; $day++){?>
<div class="calendarcont">
<div class="calendarheadercont">
<div class="calendarday"><?Php echo date("l", mktime(0, 0, 0,$month,$day,$curyear)); ?></div>
</div>
<div class="clear_1"></div>
<div class="calendarsubcont">
<div class="calendardatecont">
<div class="calendarmonth"><?Php echo date("M", mktime(0,0,0, $month,$day,$curyear)); ?></div>
<div class="calendardate"><?Php echo date("j", mktime(0,0,0,$month,$day,$curyear)); ?></div>
</div>
<div class="calendartextcont">
<div class="calendartextr"><?Php echo $availableslots; ?></div>
</div>
</div>
</div>
<?Php } ?>