ChrisAndrews
asked on
Error in while statement
Hi,
I seem to have an error in the while statement below, my 'print' prints that line three times instead of once, the proceeds to the next, then again prints it three times before moving on to the next, and so on...
I don't have much exp with this, just adapted it from another script, can you tell me what is wrong?
Thanks, Chris
--------------------------
//get data
$query = "SELECT * FROM user where Number > 0 order by Number";
$result = MYSQL_QUERY($query);
$number = MYSQL_NUMROWS($result);
/*display results*/
$i = 0;
IF ($number == 0) :
PRINT "ERROR, database seems to be out to lunch. Drop a note to Chris and he will look into it.";
ELSEIF ($number > 0) :
WHILE ($i < $number):
$ordernumber = mysql_result($result,$i,"N
$account = mysql_result($result,$i,"A
$order_date = mysql_result($result,$i,"O
$name = mysql_result($result,$i,"N
$status = mysql_result($result,$i,"S
$month1 = mysql_result($result,$i,"$
$month2 = mysql_result($result,$i,"$
$month3 = mysql_result($result,$i,"$
$month4 = mysql_result($result,$i,"$
PRINT "<tr><td>$ordernumber</td>
$i++;
ENDWHILE;
ENDIF;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
best thing to do would be to dump the table and to look through it to see what's going wrong, paste it here if you want help identifying the problem
loz
loz
ASKER
ah loz, your so smart :) dumped the table, found multiple entries, cleaned it out and all is well.... course, now I will run my scripts again and try to figure out what goofed it up in the first place. May have just been me testing over and over did something in.
Thank you,
Chris
ASKER
Hi loz,
Thank you, I am still getting three of each 'print' line, hmmm, what could be causing this?
oh, just checked the database, phpmyadmin reports 134 rows when there should 45.
When I browse the rows there is only 45 rows. I don't know what is happening there, I may need to rebuild the table?
Any thoughts? I will send these points to you because the suggested script is good, if you have any thoughts about
this let me know :)
Chris