0
SELECT date, DAYNAME(date) as day , time FROM booking WHERE date BETWEEN CURDATE() AND CURDATE() + INTERVAL 7 DAY

After query, will return result of day and its specific time. query result

and will populate the date into html table.

However, the real problem is that, when the result return more that 1 result, it will populate the table according to the number or result. example

This are the PHP code that i use to loop through result ,

function checkHari() {

    $sql = "SELECT date, DAYNAME(date) as Hari , time FROM booking WHERE date BETWEEN CURDATE() AND CURDATE() + INTERVAL 7 DAY";
    $results = mysql_query($sql);
    $num_rows = mysql_num_rows($results);

    return $results;
}

$check_hari = checkHari();


while ($row = mysql_fetch_assoc($check_hari)) {
 <?php if( $hari = 'Wednesday' ) { ?>
 <tr>
 <td>Wednesday</td>
 <?php if ($time >= 8 && $time < 10) {
  echo '<td id="Wednesday0810" class="blacked"><small>Booked</small></td>';
  } else {
  echo '<td></td>';
  } ?>
 <?php if ($time >= 10 && $time < 12) {
  echo '<td id="Wednesday1012" class="blacked"><small>Booked</small></td>';
  } else {
  echo '<td></td>';
  } ?>
 <?php if ($time >= 12 && $time < 14) {
  echo '<td id="Wednesday1214" class="blacked"><small>Booked</small></td>';
  } else {
  echo '<td></td>';
  } ?>
 <?php if ($time >= 14 && $time < 16) {
  echo '<td id="Wednesday1416" class="blacked"><small>Booked</small></td>';
  } else {
  echo '<td></td>';
  } ?>
 <?php if ($time >= 16 && $time < 18) {
  echo '<td id="Wednesday1618" class="blacked"><small>Booked</small></td>';
  } else {
  echo '<td></td>';
  } ?>
</tr>
Mat Som
  • 110
  • 1
  • 9

0 Answers0