Hi Everyone!!
Can anyone please suggest me how I can insert selected dropdown value(once user selects any of the value) in some other table.for this I am passing a dropdown value to another page, I tried it by using $_POST but error comes here is my query:
$query = "SELECT species_id FROM Species_master WHERE $_POST['species_name']";
is this the correct way of doing this.
Thanks in advance!!
Also I am passing "species_name " Because my form look like this:
<form action="tracktrees.php" method="POST" name="species" id= "species">
<input type="hidden" id = "species_scientific" name ="species_name" value ="">
<tr>
<td width="150">species_scientific_name</td>
<td width="150"><select name="species_scientific_name" onChange="getspecies_primary_common_name(this.value);getfamily(this.value);">
<?php
$sql = mysql_query("SELECT species_id,species_scientific_name FROM Species_master ");
while($row = mysql_fetch_array($sql))
{
$data2 .= "<option value='{$row['species_id']}'>{$row['species_scientific_name']}</option>";
}
echo $data2;
?>
</select></td>
</tr>
Please suggest how I can insert selected dropdown value in some other table.
How to insert dynamic dropdown selected value in other table
Moderator: General Moderators
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: How to insert dynamic dropdown selected value in other table
If you have a drop down menu you can access the information (value) like you would an array.
Your query would then look like :
Code: Select all
<?php if (is_array($_POST['species_name'])) { foreach ($_POST['species_name'] as $species_name); } ?>Code: Select all
<?php $query = "SELECT species_id FROM Species_master WHERE '$species_name' "; ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: How to insert dynamic dropdown selected value in other table
Code: Select all
$query = "SELECT species_id FROM Species_master WHERE $_POST['species_name']";
Code: Select all
$query = "SELECT species_id FROM Species_master WHERE species_name=$_POST['species_name']";
Lewis
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: How to insert dynamic dropdown selected value in other table
Yeah, correct.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
Re: How to insert dynamic dropdown selected value in other table
Thanks social_experiment" & lshaw!!
social_experiment wrote:Yeah, correct.