Re: SELECT dropdown from a db query?

From: Date: Thu, 19 Sep 2002 01:56:59 +0000
Subject: Re: SELECT dropdown from a db query?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-116826@lists.php.net to get a copy of this message
Thanks Sascha, Thought that would do the trick (at least I thought it should) but same results - a mess of single entry dropdowns. Perhaps the code should be after the 'row++;' ? Sigh . . . this is frustrating! Andre On Wednesday 18 September 2002 09:38 pm, Sascha Cunz wrote: > Change <SELECT name=rapped> to <SELECT name=rapped size=1> > > Sascha > > Am Donnerstag, 19. September 2002 03:34 schrieb Andre Dubuc: > > I'm trying to generate a dropdown SELECT list from a database query. So > > far, all I've managed to create is multiple one-item dropdowns for each > > database entry spread across the page. Bad -- very bad! > > > > I'd like normal drop-down SELECT behavior, but somehow the code escapes > > me. I've tried a bunch of permutations, but I either end up with an empty > > dropdown or multiple single entry messes. > > > > Is there anyway to iterate through this and achieve what I want? > > > > I would greatly appreciate any hints what I'm missing here or doing > > wrong. Code follows. > > Tia, > > Andre > > > > > > Code (using PostgreSQL): > > > > > > <?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); > > ?>

« previous php.general (#116826) next »