One way to fill a select box with array elements.
<html> <head> <title>Select Box</title> </head> <body> < ?php $myArray = array('cat' , 'dog' , 'mouse' , 'cow'); ?> <select name="myselect"> <option value=""></option> // Sets blank entry *optional* < ?php foreach($myArray as $value){ // Loop through each element print("<option value=\"$value\">$value<option>"); } ?> </option></select> </body> </html>
Technorati Tags: php, select, drop down

May 20th, 2008 at 2:16 pm
Thanks, I was having trouble with this.