Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
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
Old 06-24-2004, 09:33 PM   #2 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Not to be rude, but how can we possibly know what the loop is supposed to do or what values you expect? Can you be more specific as to what the loop is supposed to do and / or walk us through your application?
bdl is offline   Reply With Quote
Old 06-25-2004, 12:07 PM   #3 (permalink)
sammy
Code Monkey
 
sammy's Avatar
 
Join Date: Jun 2004
Location: Brooklyn/Rochester
Posts: 53
sammy is on a distinguished road
Send a message via AIM to sammy
Doesnt seem like theres anything wrong with your loop, but it seems there might be faulty data in ur DB? Did you try executing that query and seeing what table it returns?
__________________
sammy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
do-while loop M3GAPL3X Standard C, C++ 4 06-26-2003 09:57 PM
Breaking out of external loop agh Standard C, C++ 7 04-30-2003 08:03 PM
the endless loop loop loop loop loop loop ... abc123 All Other Coding Languages 2 08-14-2002 03:43 PM
cgi not working on a new script sde PHP 3 05-20-2002 08:29 PM


All times are GMT -8. The time now is 04:48 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting