I'm not sure what I am doing wrong but basically I'm trying to out put the days of the month through an array(done) but that dates that are within a booking date range from my trips table have a different appearance to them, this is how it currently looks
http://oi60.tinypic.com/2zzrc03.jpg
Where I am trying to output like this..
March 1[2 3 4 5]6[7 8 9 10]
The code is working for the most part but for months that have multiple events it's repeating the month and showing the days in their own month row
Here is my code, yes I am aware about it being mysql but currently this is a local project so I am working to get it functioning before I move to that step.
<table width="100%" cellspacing="0">
<?php
$cmonth = date('F');
$cyear = date('Y');
$sql = "SELECT * FROM calendar WHERE year = '$cyear' ORDER BY m_order ASC";
$res = mysql_query($sql);
while ($rows = mysql_fetch_array($res)) {
$month_end = $rows['days_in_month'];
$month_name = $rows['month_name'];
$m_order = $rows['m_order'];
$sql2 = "SELECT * FROM trips WHERE start_date LIKE '____-0$m_order-__' ORDER BY start_date ASC";
$res2 = mysql_query($sql2);
while ($row = mysql_fetch_array($res2)) {
$stdate = $row['start_date'];
$s = date_parse_from_format("Y-m-d", $stdate);
$endate = $row['end_date'];
$e = date_parse_from_format("Y-m-d", $endate);
$start = $s['day'];
$end = $e['day'];
?>
<tr>
<td width="80px"><?php echo $month_name; ?></td>
<?php
foreach(range(1, $month_end) as $days)
{
if(in_array($days, range($start, $end)))
{
echo "<td style=\"background-color: #ccc;\" align=\"center\">". $days ." </td>";`
}
else
echo "<td align=\"center\">". $days ."</td>";
}
?>
</tr>
<?php }
} ?>
</table>
I'm just wondering if my coding is wrong or if I should be trying to accomplish my goals with an alternative method? any suggestions appreciated.