DSM Design > PHP Code Snippets Episode 2
PHP Code Snippets Episode 2

In this post I am going to show you how to take the values from an array and use them, in a form option box. First of all we are going to make a simple array…
For this example i will just make a basic array, however you could use a<em> mysql_fetch_array()</em> to read data from a database to make your array then continue with step 2.
I will show you the basics of this in my next tut.
<pre class=”syntax”><!–?php $options = array(“option_1″,”option_2″,”option_3″,”option_4″,”option_5″,”option_6″); ?–>
</pre>
<form><select name=”example”><!–?php foreach($options as $choice) { echo ‘<option value=”‘.$choice.'”>’.$choice.’&lt;/option>’; } ?–></select></form>
As you can see this will give you all the options from the array into your option choices.
I hope this little snippet will help.