insert data from dropdown-menu list into mysql table
Moderator: General Moderators
-
phpDVWeaver
- Forum Commoner
- Posts: 28
- Joined: Sun Apr 29, 2007 11:00 pm
insert data from dropdown-menu list into mysql table
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
Re: insert data from dropdown-menu list into mysql table
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.
-
phpDVWeaver
- Forum Commoner
- Posts: 28
- Joined: Sun Apr 29, 2007 11:00 pm
feyd | Please use
I need to add these values to a MySql table called projArea that has the following definition:
hope it's clearer now.
feyd | Please use[/syntax]
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)feyd | Please use[/syntax]
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]- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
-
phpDVWeaver
- Forum Commoner
- Posts: 28
- Joined: Sun Apr 29, 2007 11:00 pm
-
phpDVWeaver
- Forum Commoner
- Posts: 28
- Joined: Sun Apr 29, 2007 11:00 pm
foreach does not take a dropdown menu as an array! any idea
this is my 'list'
here I assign the variables
here I use the foreach to insert values in the table project.
but this is the message I got.
Warning: Invalid argument supplied for foreach()
Can anyone drop an idea.
Again what I am trying to do is to insert ALL the data in a dropdown menu into a mysql table (I am not dedealing with only selected values here)
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());
}Warning: Invalid argument supplied for foreach()
Can anyone drop an idea.
Again what I am trying to do is to insert ALL the data in a dropdown menu into a mysql table (I am not dedealing with only selected values here)
-
phpDVWeaver
- Forum Commoner
- Posts: 28
- Joined: Sun Apr 29, 2007 11:00 pm
-
phpDVWeaver
- Forum Commoner
- Posts: 28
- Joined: Sun Apr 29, 2007 11:00 pm