By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,077 Members | 2,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,077 IT Pros & Developers. It's quick & easy.

problem with to select multiple items

100+
P: 118
hi

i wrote a code to select multiple items in a drop down list.And i store all the items in my database.But in that i select multiple items and submit that items last item only stored.Please tell that what's the mistake in my code.

[php]

<td><select name="imagelist" id="imagelist" multiple="multiple">
<?
while($row=mysql_fetch_array($result))
{
$i=1;
$urlname=$row['urlname'];
?>

<option value="<?=$urlname?>"><?=$ext=strrchr($urlname,'/');?></option>

<?
}
?>
</select>
[/php]

And i store these items in a database with a name $_POST['imagelist'].

Anybody plz tell that whats the mistake in my code.plz help me.
Jul 25 '08 #1
Share this Question
Share on Google+
4 Replies


10K+
P: 13,264
Post the code you used to save the values.
If you connect to the database say, through the command line, do you see all the values stored there or just the last one as well?
Jul 25 '08 #2

100+
P: 118
Post the code you used to save the values.
If you connect to the database say, through the command line, do you see all the values stored there or just the last one as well?

i want to store all the items selected in drop down list.
Jul 25 '08 #3

10K+
P: 13,264
i want to store all the items selected in drop down list.
You haven't answered my question and you still haven't posted the code you used to store the multiple values ...
Jul 25 '08 #4

10K+
P: 13,264
Now that I've looked at your code again, your select name should have [] added to it.

i.e
Expand|Select|Wrap|Line Numbers
  1. <select name="imagelist[]" .... 
Then the code that retrieves it does something like
Expand|Select|Wrap|Line Numbers
  1. $imagelist = $_POST['imagelist'];
and at that point imagelist is an array.
Jul 25 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.