Jump to content

Day preview


jimmyfoxe

Recommended Posts

I am making an agenda where visitors can select a day to preview which time-period is still available to book an oppointment.

After the selection of a day, a 3-colomn overview is appears. The time is from 9:30 till 22:30 (so, each colomn has 9 time-periods) of 30 minutes each.

 

But the problem is, when I have 3 results in my database on the same day, I get 3 times the same 3-colomn overview (as a result of which I get 9 colomns beside each other). In each of the 3-colomn i have just 1 result. Idem dito for 10 results on the same day, I get 10x 3-colomn overview which is not the intention. Who can help me fixing this problem?

echo '<div class="t_subtitle">Dagoverzicht</div>' .PHP_EOL;
$sQueryA = "SELECT datum, DATE_FORMAT(begintijd, '%H:%i') AS forbegintijd, DATE_FORMAT(eindtijd, '%H:%i') AS foreindtijd FROM sint_reserveringen WHERE datum = '".date('Y-m-d', $_GET['datum'])."' ORDER BY begintijd ASC";
if (!$sResultA = mysql_query($sQueryA)) {
    echo '<div class="queryerror">Error ... - Query kan niet uitgevoerd worden!<br />'.mysql_error().'<br />'.mysql_errno().'</div>' .PHP_EOL;
} else {
    $iNumA = mysql_num_rows($sResultA);
    if ($iNumA > 0) {
       
	$dagtijd = array(
		"1" => array("09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30"),
		"2" => array("14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00"),
		"3" => array("18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30")
	);

        echo '<table>';
        for ($i = 0; $i <= 8; $i++) {
            echo '<tr>';
            for ($j = 1; $j <= 3; $j++) {
                if ($j % 2 == 1) {
                    while ($objA = mysql_fetch_object($sResultA)) {
                        if (($objA->forbegintijd <= $dagtijd[$j][$i]) && ($objA->foreindtijd >= $dagtijd[$j][$i])) {
                                echo '<td align="center" style="background-color:#FFFFFF;"><strong>'.$dagtijd[$j][$i].'</strong>';
                        } else {
                                echo '<td align="center" style="background-color:#FFFFFF;">'.$dagtijd[$j][$i];
                        }
                    }
                    mysql_data_seek( $sResultA, 0 );
                } else {
                    while ($objA = mysql_fetch_object($sResultA)) {
                        if (($objA->forbegintijd <= $dagtijd[$j][$i]) && ($objA->foreindtijd >= $dagtijd[$j][$i])) {
                                echo '<td align="center" style="background-color:#FFFFFF;"><strong>'.$dagtijd[$j][$i].'</strong>';
                        } else {
                                echo '<td align="center" style="background-color:#FFFFFF;">'.$dagtijd[$j][$i];
                        }
                    }
                    mysql_data_seek( $sResultA, 0 );
                }
                echo '</td>';
            }
            echo '</tr>';
        }
        echo '</table>';

    }
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.