Re: [PHP4BETA] re:Populating a Select Dynamically

From: Date: Fri, 17 Mar 2000 00:20:56 +0000
Subject: Re: [PHP4BETA] re:Populating a Select Dynamically
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-12294@lists.php.net to get a copy of this message
if you put the echo inside the loop instead of outside then you'd get what you want. Allen Lee Assistant Sysadmin http://MissoulaWeb.com Hosting, Programming and Design On Fri, 17 Mar 2000, Joseph H Blythe wrote: > Hey PHPers, > > I am trying to write a piece of code that would populate the contents of > a select box dynamically with a results from a mysql Select. > > This is sort of what I am trying to achieve.... > > $details=mysql_query("SELECT * FROM table_name"); > while ( $row = mysql_fetch_row($details) ) { > > $i=0; > $Na=$row[1]; > $Ops[$i]="$Na"; > $i++; > } > > .echo "<select name='selectNa' size='12'>"; > > $j=0; > while ( $j < $i ) { > $Op="$Op$Ops[$j]"; > echo "<option> value='$Op'>$Op</option>"; > $j++; > } > > echo "</select>"; > > Well this seems to create one option in the select anyway the last value > of $Na in the list. > Can anyone see what I am doing wrong I am still a little fuzzy with > arrays. > > Any help would be much appreciated. > > Joseph Blythe > > mailto:joe.blythe@binarylogic.com > > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net > >

« previous php.version4 (#12294) next »