Re: while loop question - problem (new set of eyes needed)
| From: | Julie Meloni | Date: | Sun, 19 May 2002 23:25:11 +0000 |
| Subject: | Re: while loop question - problem (new set of eyes needed) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98398@lists.php.net to get a copy of this message | ||
LPR> --------------------------------------------
LPR> while($row = mysql_fetch_array($result))
LPR> {
LPR> $pri = $row['pri'];
LPR> $fg = $row['fg'];
LPR> $molw = $row['molw'];
LPR> $density = $row['density'];
LPR> $denstype = $row['denstype'];
LPR> $pctd = $row['pctd'];
LPR> $maxpctd = $row['maxpctd'];
LPR> $compid = $row['compid'];
LPR> $sql = "select * from compounds where compid = \"$compid\"";
LPR> $result = mysql_query($sql,$conn);
LPR> $row = mysql_fetch_array($result);
LPR> $compname = $row['compname'];
LPR> $concentration = $row['concentration'];
LPR> $concunit = $row['concunit'];
LPR> $type = $row['type'];
LPR> $composition = $row['composition'];
LPR> if ($fg=="Y")
LPR> $html .= "<b>$concentration $concunit $compname</b><br>";
LPR> else if ($pri=="Y")
LPR> $html .= "<font color=\"#000066\"> $concentration $concunit
LPR> $compname</font><br>";
LPR> else
LPR> $html .= " $concentration $concunit $compname<br>";
LPR> }
LPR> --------------------------------------------
You are re-assigning the value of $row within the while construct.
When you get to your query within the while chunk, use different
variable names than the "master".
- Julie
--> Julie Meloni
--> julie@thickbook.com
--> www.thickbook.com
Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20