Problem with a For-Loop. Please help.
Posted: Tue Apr 03, 2007 1:27 am
I have a page that is going to print out the orders a customer has open. In the start I have an if statement that is going to see if there are any rows in the record set from a query. If there are none it prints out "No Orders In Progress". This part works fine.
But if there are rows in the record set it goes into a for loop that will use variable $i to increment through the recordset. My problem seems to be coming from the for loop, I think. I went through and commented out everything after the else and it printed out "No Orders In Progress" perfectly. But after I uncommented out the php code within the span tags, but left the for loop declaration commented out, it worked fine. I'm not sure what it can be. Could someone look over it and let me know if they see something please. Here's the code:
I have marked where I put the comment slashes and it worked. I don't know what's up, I've been looking at this for hours and I'm clueless. Thanks for all the help in advance.
But if there are rows in the record set it goes into a for loop that will use variable $i to increment through the recordset. My problem seems to be coming from the for loop, I think. I went through and commented out everything after the else and it printed out "No Orders In Progress" perfectly. But after I uncommented out the php code within the span tags, but left the for loop declaration commented out, it worked fine. I'm not sure what it can be. Could someone look over it and let me know if they see something please. Here's the code:
Code: Select all
<div id="generic">
<div id="left_column">
<div class="grey_block"> <span class="subtitle">Orders</span>
<?php if(!mysql_num_rows($orders)) { ?>
<span class="block">No Orders In Progress</span>
<?php } else {
for($i=0;$i<=mysql_num_rows;i++) {?> // <----- if you comment out this line and line marked below it works.
<div class="block"> <span class="inline">Order Number: </span> <span class="inline"><?php echo mysql_result($orders,$i,0); ?></span>
</div>
<div class="block"> <span class="inline">Date Ordered: </span> <span class="inline"><?php echo mysql_result($orders,$i,3); ?></span>
</div>
<div class="block"> <span class="inline">Currently: </span> <span class="inline"><?php echo mysql_result($orders,$i,5); ?></span>
</div>
<?php if(mysql_result($orders,$i,5) == "complete") { ?>
<div class="block"> <span class="inline">Date Complete: </span> <span class="inline"><?php echo mysql_result($orders,$i,4); ?></span>
</div>
<?php }
} // <---- not sure if I need any ";" here or not. But if you comment out this curly brace, and above, it works.
} ?>
</div>
</div>
</div>