Jump to content

[SOLVED] multi select post to db


trampolinejoe

Recommended Posts

Hello Guys,

 

I need help, I am still abit of a newbie at all this,

 

I have a multi select box thats actually created in php and fills up from the db ( i used a example i found online to make this)

echo" <select name='product' id='product' size='5' tabindex='11' class='validate required product productMsg' multiple>";                      //start the select box 

					$results= mysql_query("SELECT ID, name FROM Products ORDER BY ID asc",$connection); 
					$id = "ID";
					$idname = "Name"; 
					echo mysql_error(); 

						if (mysql_Numrows($results)>0)                            //if there are records in the fields
						{ 
						  $numrows=mysql_NumRows($results);                       //count them
						  $x=0; 
						  while ($x<$numrows){   //loop through the records
							$theId=mysql_result($results,$x,$id);                 //place each record in the variable everytime we loop
							$theName=mysql_result($results,$x,$idname);
							echo "<option value=\"$theId\">$theName</option>\n";  //and place it in the select
							$x++;
						  }
						}
					echo "</select>";  //close the select


 

anyways

 

we end up with something such as this:

<select name='product' id='product' size='5' tabindex='11' class='validate required product productMsg' multiple>

<option value="150">sampleProduct</option>
<option value="151">10 Ft Trampoline</option>

</select>

 

 

which is great, but the thing is, i need to be able to select more then one item then post it to the DB.

 

currently if I post a 2 selected items only 1 manages to actually get posted.

 

I am guessing i need some kind of array to post the multiple values with, but to be honest I have no idea what to do? / how to do it?

 

Can anybody please help me?

 

cheers.

 

Link to comment
https://forums.phpfreaks.com/topic/133740-solved-multi-select-post-to-db/
Share on other sites

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.