php: Dynamically fill a select box
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>
Categories: Programming, php
Thanks, I was having trouble with this.
This is a very good site.
Well I really enjoyed reading it. This post offered by you is very helpful for correct planning.
prodigious post you’ve own
Of course, what a great site and advisory posts, Can I add backlink – import your rss feed? Regards, Reader.
[url=http://www.shop-soccer-jerseys.com/]Cheap FootBall Shirts[/url]
I just read through the entire article of yours and it was quite good. This is a great article this informative information. I will visit your blog regularly for some latest post.