re:Populating a Select Dynamically
| From: | Joseph H Blythe | Date: | Fri, 17 Mar 2000 00:22:24 +0000 |
| Subject: | re:Populating a Select Dynamically | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12293@lists.php.net to get a copy of this message | ||
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