Re: trying 2 pull data out table and populate a list box

From: Date: Fri, 29 Oct 2004 10:16:58 +0000
Subject: Re: trying 2 pull data out table and populate a list box
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-200614@lists.php.net to get a copy of this message
On Fri, 29 Oct 2004 09:52:49 +0200, Reinhart Viane <rv@domos.be> wrote: > I always do this with a script like this: > > $sql="select * from ladders order by laddername"; > $rsladders=mysql_query($sql); > $aantal_ladders=mysql_num_rows($rsladders); > > for($x=0;$x<$aantal_ladders;$x++) > { > $rijladders["$x"]=mysql_fetch_array($rsladders); > } if ( mysql_num_rows( $rsladders ) ) { while ( $rijladders = mysql_fetch_array( $rsladders ) ) { echo <<<EOF <option value="$rijladders[ladder_id]">$rijladders[laddername]</option> EOF; } } > > And then to populate the list: > <select name="ladder" id="select"> > <?PHP > for($x=0;$x<$aantal_ladders;$x++) > { > echo('<option > value="'.$rijladders["$x"]["ladder_id"].'"'); > > echo('>'.$rijladders["$x"]["laddername"].'</option>'); Like I wrote above, I tend to use heredoc syntax for stuff like this. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/

« previous php.general (#200614) next »