View Single Post
Old 06-24-2004, 07:11 PM   #1 (permalink)
alemily
Registered User
 
Join Date: Jun 2004
Posts: 1
alemily is on a distinguished road
Question While loop not working

I've been pulling my hair out the last few days trying to figure out why this loop will not work.
PHP Code:
<?php 
$start_c 
mktime(800$month_t$day_t$year_t);
$end_c mktime(1700$month_t$day_t$year_t);

$loop_s $start_c;
$loop_e $end_c;

while(
$loop_s $loop_e)
{
    
$time_start $loop_s;
    
$loop_s $loop_s+1800;
    
$time_end $loop_s;
    
$unix_e $time_end-1;
    
$unix_s date("U"$time_start);

    
// make times human readable
    
$timeloop_e date("g:i A"$time_end);
    
$timeloop_s date("g:i A"$time_start);
    print(
"<tr><td bgcolor=\"#004C91\">"$timeloop_s ." - "$timeloop_e "</td>");

    
$query "SELECT event_start FROM event_list WHERE UNIX_TIMESTAMP(event_start) >= $unix_s AND UNIX_TIMESTAMP(event_start) <= $unix_e ORDER BY UNIX_TIMESTAMP(event_start) DESC";
    
$result mysql_query($query) or die(mysql_error());
    if (
mysql_num_rows($result) == 0)
    {
    print (
"<td bgcolor=\"#B87700\">Timeslot Open</td></tr>\n");
    }
    else 
    {
    print (
"<td bgcolor=\"#333333\">Reserved</td></tr>\n");
    }
    
$loop_s++;
}

?>
I am trying to get this code to output as (for example a class is between 9:00 am and 11:00 am):

| 8:00-8:30 | Timeslot Open |
| 8:30-9:00 | Timeslot Open |
| 9:00-9:30 | Reserved |
| 9:30-10:00 | Reserved |
| 10:00-10:30 | Reserved |
| 10:30-11:00 | Reserved |
| 11:00-11:30 | Timeslot Open|

But it shows up as:

| 8:00-8:30 | Timeslot Open |
| 8:30-9:00 | Timeslot Open |
| 9:00-9:30 | Reserved |
| 9:30-10:00 | Timeslot Open |
| 10:00-10:30 | Timeslot Open|
| 10:30-11:00 | Timeslot Open|
| 11:00-11:30 | Timeslot Open|


If there is anyone here who can see where I went wrong, I'd would be grateful.

Thanks.
alemily is offline   Reply With Quote