Multiple select by array

I have:

$selectedItem = '100,200,300';

And mysql load:

<select multiple="multiple" name="product_id">
   <?php
   $query = mysql_query("SELECT * FROM products ORDER BY id");
   while($row = mysql_fetch_array($query)){
      echo '<option value="$row[id]">$name</option>';
   }
   ?>
</select>

And I need $selectedItem (three values) to be:

<option value="$row[id]" selected>$row[id]</option>

How can I do that? I just can’t find the solution when the selectedItem more than 1.

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories