Jump to content

multiple select and mysql (help)


janim

Recommended Posts

hello guys

<select name="time" size="4" multiple="multiple">
	<option selected="selected">None Selected</option>
	<option>Full Time</option>
        <option>Part Time</option>
        <option>Contract</option>
        <option>Temporary</option

you know this select but who know how to enter all of selected values to database

couse when i tried to submit the form it's insert just one value from all values selected

so how can i fix it

Best Regards

A janim

Link to comment
https://forums.phpfreaks.com/topic/63374-multiple-select-and-mysql-help/
Share on other sites

the key to mutiple selects is to assign it an array name, so php interprets it as an array.

 

<select name="time[]" size="4" multiple="multiple">

 

to use those values use this simple code

 

$arr = $_POST['time'];
foreach($arr as $time){
   echo $time . "<br />";
}

thank you GuiltyGear

it works in echo $time;

but i want to send it to mysql

like this it goes nothing just one value

$insert=mysql_query("insert into $table values ('NULL', '".$_POST['time']."')")

i tried this

$insert=mysql_query("insert into $table values ('NULL', '".$time."')")

it store "array" word in database

so thank you again for your replay  :) :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.