Link to home
Start Free TrialLog in
Avatar of Bill Sullivan
Bill SullivanFlag for United States of America

asked on

PHP "while" command not working properly

Hi Experts:
I'm completely missing something here.  I have a simple MYSQL query in my PHP code that for some reason is not giving me the expected results.  I have a table with 4 records in it that should be fetched from my SELECT command.  Yet, when I instigate a "while" loop to collect data from these four records, it returns zero values and only looks at one record.  Here is the PHP code:
$CurbFlashingSF = 0;
		$queryCurbFlashing = mysql_query("SELECT * FROM CurbFlashing WHERE ClientFile='$ClientFile'");
		$num_rowsCurbFlashing = mysql_num_rows($queryCurbFlashing);
		if($num_rowsCurbFlashing > 0)
				$CurbFlashingLength = $rowCurbFlashing['Length'];
				echo "Curb Flashing Length: ".$CurbFlashingLength,"<br />";
				$CurbFlashingSO = $rowCurbFlashing['Stretchout'] /12;
				echo "Curb Flashing SO: ".$CurbFlashingSO;
				$CurbFlashingBends = $rowCurbFlashing['Bends'];
				$CurbFlashingSF = $CurbFlashingSF + ($CurbFlashingLength * $CurbFlashingSO);

Open in new window

As I said, there are four records in the table with the Client File number I'm looking for.  The results on my page are shown on the attached screen shot.  As there are four records, I would have expected four results, but something is causing it to exit out of the "while" loop.

Can you please help me figure out why my results aren't showing me what I expect?

Thanks so much!
Avatar of gr8gonzo
Flag of United States of America image

What happens when you echo $num_rowsCurbFlashing ?
Avatar of Bill Sullivan


It returns "4" as expected.
Here is a screen shot of what is in the table.
On Line 10, you have a comma instead of a period towards the end. I think you mean to use a period. I don't see why that would exit the loop, but it's something to try.
Thanks for catching that.  I replaced the comma with a period and re-sent the query - same result.
Avatar of StingRaY
Flag of Thailand image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much!  Sometimes when you look too hard at a code stuff gets missed.  I appreciate your timely response!!!!