Hi
This is hard to explain but I’ll try I am designing a booking system for my business, which will look something like this:
say with each hour cell ie 9am next to it split 2 cells with 9:00 & bottom cell 9:30
I have two loops one that runs the 7days a week and inside that the hours of the day, if I have one cell per hour its easy to fill it in as its all in order,
all the TD and TR are in the right order but with a spilt row the data is all over the place. How can i get the data in the correct cells when I am using loops to build the hours and days. Any help or ideas would be great. Main code I am using is at bottom
<table width=“600” border=“1” cellpadding=“0” cellspacing=“0”>
<tr>
<td> </td>
<td>28th April </td>
<td>29th April</td>
<td>30th April </td>
</tr>
<tr>
<td rowspan=“2”>9am</td>
<td>9:00am</td>
<td rowspan=“2”>empty</td>
<td>8:30am 2 </td>
</tr>
<tr>
<td>9:30am</td>
<td>9:30am 2 </td>
</tr>
<tr>
<td>10am</td>
<td>booked</td>
<td>booked</td>
<td>booked</td>
</tr>
</table>
if($book==Y)
{
$query = “INSERT INTO tblTimeSlot SET slotID=‘123’, slotStart=‘$slotStart’, slotFinish=‘$slotFinish’, status=‘Booked’”;
mysql_query($query,$db);
}
//variables
$hourStart = 9;
$hourFinish = 17;
$slotDuration = 25;
$slotsPerHour = 60/$slotDuration;
$slotsPerHour = round($slotsPerHour,2);
echo $slotsPerHour;
if($nextWeek!=“”)
{
$date = strtotime(“$day-$month-$year GMT”);
$todayNow = $date + 604800;
echo $todayNow;
}
else
{
$todayNow = time();
}
$dateDay = date(‘D’, $todayNow) ;
$dateNum = date(‘j’, $todayNow) ;
$dateYear = date(‘Y’, $todayNow);
$dateMonth = date(‘n’, $todayNow);
?>
</p>
<p> </p>
<?
echo(“<a href=‘/test5.php?nextWeek=Y&day=$dateNum&month=$dateMonth&year=$dateYear’>Next Week</a>”);?>
<table width=“900” border=“1” cellpadding=“0” cellspacing=“0”>
<tr><td>time</td>
<?
// create top row of days for current timr
for($i =0; $i<7; $i++)
{
$time = 86400 * $i;
$newTime = $todayNow + $time;
$dateDay = date('D', $newTime) ;
$dateNum = date('j', $newTime) ;
echo("<td>$dateDay $dateNum</td>");
}
?>
</tr>
<?
//$todayNow = time();
$dateDay = date(‘D’, $todayNow) ;
$dateNum = date(‘j’, $todayNow) ;
$dateYear = date(‘Y’, $todayNow);
$dateMonth = date(‘n’, $todayNow);
// hourly time slot rows + needs 7 vertical columns for time
for($h=$hourStart; $h<=$hourFinish; $h++)
{
echo(“<tr>”);
// columns 7 for each day
for($c = 0; $c <7; $c++)
{
$time = 86400 * $c;
$newTime = $todayNow + $time;
$dateNum = date('j', $newTime);
$dateYear = date('Y', $newTime);
$dateMonth = date('M', $newTime);
// build up date and time from $h
$timeStamp = "$dateNum $dateMonth $dateYear $h:00 GMT";
$unix = strtotime($timeStamp);
// display left column time //
if($c==0)
{
// display hour column on left
if($h>12 && $h<=23)
{
$columnTime = $h - 12;
$columnTime = $columnTime ."pm";
}
else
{
$columnTime = $h."am";
}
echo("<td>$columnTime</td>");
}
// end of column time //
// check booking and display on screen
$query = "SELECT status FROM tblTimeSlot WHERE slotStart='$unix'";
$result = mysql_query($query,$db);
if(!$row = mysql_fetch_array($result))
{
$showTime = gmdate("g:ia",$unix);
$slotFinish = $unix+(60*$slotDuration);
echo("<td>$showTime<br>
<a href='/test6.php?book=Y&slotStart=$unix&slotFinish=$slotFinish'>$unix</a></td>");
}
else
{
$status = $row[status];
echo("<td>$status</td>");
}
}
echo("</tr>");
}
?>
</table>