insert data from dropdown-menu list into mysql table
Posted: Mon Jun 11, 2007 3:15 pm
can any one show me how to be able to insert all the values in a list (dropdown-menu list of size 5) into the table.
Thanks
Thanks
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
What table? What records? What fields? What are you trying to do?phpDVWeaver wrote:can any one show me how to be able to insert all the values in a list (dropdown-menu list of size 5) into the table.
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
sorry for not being that clear;
I do have a dropdown-menu that can show 5 values at the sametime, example:
[syntax="html"]
<select name="projarea" size="5">
<option>Bionanotechnology</option>
<option>Computational Nanotechnology</option>
<option>Nanaocharacterization</option>
<option>Nanoelectromechanical System</option>
<option>Nanoelectronics</option>
<option>Nanofabrication</option>
<option>Nanomanufacturing</option>
<option>Nanomaterials</option>
<option>Nanophotonics</option>
</select>Code: Select all
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
area VARCHAR(100)Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<select name="projarea" size="5">
<option>Bionanotechnology</option>
<option>Computational Nanotechnology</option>
<option>Nanaocharacterization</option>
<option>Nanoelectromechanical System</option>
<option>Nanoelectronics</option>
<option>Nanofabrication</option>
<option>Nanomanufacturing</option>
<option>Nanomaterials</option>
<option>Nanophotonics</option>
</select>Code: Select all
$projtitle = trim($_POST['projtitle']);
$projurl = trim($_POST['projurl']);
$projarea = trim($_POST['projarea']);Code: Select all
foreach($projarea as $tempprojarea)
{
$query = "INSERT INTO project(projtitle, projurl,projarea) VALUES ('$projtitle', '$projurl','$tempprojarea')";
mysql_query($query) or die("Query failed: " . mysql_error());
}