HOW-to: PHP Multiple Select List Box quick and easy..

On December 30, 2009, in How-to, Scripting, by Cubert aka (Cube Dweller)

Sometimes you find that it requires a little looping to get data from a form when using PHP and Mulitple select list boxes. Here is a quick and easy way to loop through select data sent from a form in html. We also show you here how to use a Array of data to create the options. This is great if your doing a database query and need to use that data in select box.


select id="select[]" multiple="multiple" name="select[]" size="10"

option value=" . $listID . ">" .$listItem. ""; } /option /select

input id="button" name="button" type="submit" value="Submit" /

if (isset($_POST['select'])) {
$az = $_POST['select'];
foreach ($az as $a)
echo $a;


Tagged with:

2 Responses to “HOW-to: PHP Multiple Select List Box quick and easy..”

  1. Manoj says:

    how to set values to multiple list box using php

  2. Hello there I am so glad I found your blog page, I really found you by accident,
    while I was searching on Yahoo for something else, Regardless
    I am here now and would just like to say many thanks for
    a marvelous post and a all round interesting blog (I also
    love the theme/design), I don’t have time to browse it all at the moment but I have bookmarked it
    and also included your RSS feeds, so when I
    have time I will be back to read much more, Please do keep up the superb work.

Leave a Reply