Re: SELECT dropdown from a db query?
| From: | Jacob Miller | Date: | Thu, 19 Sep 2002 01:54:46 +0000 |
| Subject: | Re: SELECT dropdown from a db query? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116827@lists.php.net to get a copy of this message | ||
Move <select></select> outside the do-while loop:
print "<SELECT name=rapped>";
$row = 0;
do
{
$myrow = pg_fetch_array($result,$row);
if ($myrow['rupload'] != "") {
print "<option>{$myrow['rfname']} {$myrow['rsname']}</option>";
}
$row++;} while ($row < $numrows); print "</select>"; pg_close($db); -- - Jacob At 09:56 09/19/2002, Andre Dubuc wrote:
<?php . . . $query = "SELECT * FROM rap WHERE rsponsor = '{$_SESSION['sid']}'"; $result = pg_exec($db, $query); if (!$result) {exit;} $numrows = pg_numrows($result); if ($numrows == 0) {echo "<h2>Sorry!<br><br>'{$_POST['sid']}' is not in the our database.<br><br> Click 'Back' on your browser to enter another search.<br><br></h2>"; exit;} $row = 0; do { $myrow = pg_fetch_array($result,$row); if ($myrow['rupload'] != "") { print "<SELECT name=rapped><option>{$myrow['rfname']} {$myrow['rsname']}</select>"; } $row++; } while ($row < $numrows); pg_close($db); ?>