You are resetting $row inside your loop. Don't do that.
On Sun, 19 May 2002, Lee P Reilly wrote:
> Hi,
>
> I wonder if someone could have a quick look at this for me? It's a
> simple while loop, but it's not acting the way (I think) it should. If I
> break down the while loop, it reads:
>
> --------------------------------------------
> // $result contains 3 rows
> while($row = mysql_fetch_array($result))
> {
> echo " xxx ";
> }
> --------------------------------------------
> => xxx xxx xxx is displayed (as expected)
>
> If I add the following code to the loop, it only seems to iterate
> through it *once*:
>
> --------------------------------------------
> while($row = mysql_fetch_array($result))
> {
> $pri = $row['pri'];
> $fg = $row['fg'];
> $molw = $row['molw'];
> $density = $row['density'];
> $denstype = $row['denstype'];
> $pctd = $row['pctd'];
> $maxpctd = $row['maxpctd'];
> $compid = $row['compid'];
>
> $sql = "select * from compounds where compid = \"$compid\"";
> $result = mysql_query($sql,$conn);
> $row = mysql_fetch_array($result);
>
> $compname = $row['compname'];
> $concentration = $row['concentration'];
> $concunit = $row['concunit'];
> $type = $row['type'];
> $composition = $row['composition'];
>
> if ($fg=="Y")
> $html .= "<b>$concentration $concunit $compname</b><br>";
> else if ($pri=="Y")
> $html .= "<font color=\"#000066\"> $concentration $concunit
> $compname</font><br>";
> else
> $html .= " $concentration $concunit $compname<br>";
> }
> --------------------------------------------
>
> Expected results:
> --------------------------------------------
> Actin #2543: Description here.
>
> 1 mol AEBSF
> 1.3 mol Calcium Chloride
> 1.4 mol Potassium Chloride
> --------------------------------------------
>
> Actual results:
> --------------------------------------------
> Actin #2543: Description here.
>
> 1 mol AEBSF
> --------------------------------------------
> i.e the last two compounds are not displayed.
>
> I can't for the life of me see the problem. A new set of eyes looking at
> this would be GREATLY appreciated. Thanks very much in advance.
>
> - Best regards,
>
> Lee
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php