How to insert dynamic dropdown selected value in other table
Posted: Thu Feb 04, 2010 7:06 am
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.
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.