Re: loop weirdness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 Aug 2008, at 15:58, Dan Shirah wrote:
I'm having some weirdness with a loop. I am adding an conditional statement to my script to see if a condition is met before running a loop. All of the code up to this point works great so I have not included it since it is very long and extensive. Basically I have a query that runs and is output to
$info.  This is where the code below picks up.

Whenever I add the if() I only get one result returned. But if I simply
delete the if() statement I get all of the rows returned.

Is there some weirdness where the closing backet of the if() statement gets
interpretted by PHP to be the closing bracket of the while loop?

print_r($row); does display all of the results from my query so I know they are in there. So the only thing I could think of is the curly braces being
used for the while() before the if()

<?php
if ($f_date!="") { // Start of IF
 while ($row = ifx_fetch_row($info)) { // Start of While
 $case_date = $row['caa61140005'];
 $case_type = substr($row['caa38840002'], 4);
 $case_id = $row['caa443400018'];
 $case_num = TRIM($row['caa44340041']);
 $case_title = TRIM($row['caa44340002']);
 $case_category = TRIM($row['caa443400013']);
 print_r($row);
} // End of IF
?>
<tr>
<td width='300' id="<?php echo $case_num; ?>" height='13' align='center'
class='tblcell'><div align='left' id="<?php echo $case_num; ?>"><img
src="Images/Next1.gif"><a href="javascript:caseDetail('<?php echo $case_id; ?>','<?php echo $case_title; ?>','<?php echo $party_name; ?>','<?php echo
$case_num; ?>')"><?php echo $party_name."<br />\n".$case_num;
?></a></div></td>
</tr>
<?php
} //End of While
?>

Any ideas?

Your comments indicate you're trying to end the if in the middle of the while, but what PHP will be doing is ending the while where you want to end the if. I assume what you actually want to do is end both after the HTML is output, but I'm just guessing.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux