Hi Everyone,
I am new in php world, I am able to display a drodown list having all the fields from a table called species_master, but not able to print, i got this code from a website, not sure I really need to use it, working but later I also need to store it into some other table kind of stuff..
Here is code for "display dropdown list for all the table fields.
PHP CODE
$sql = mysql_query("SELECT species_primary_common_name FROM Species_master ORDER BY species_primary_common_name");
while($row = mysql_fetch_assoc($sql))
{
$data1 .= "<option value='{$row['species_id']}'>{$row['species_primary_common_name']}</option>";
}
HTML CODE-
<tr>
<td align=right>Species Primary Common Name:</td>
<td>
<select id="species_master" name="data1" style="width: 222px;">
<?php
echo $data1;
?>
</select>
</td>
</tr>
Please Can Anyone suggest me how easily i can solve this issue..Thanks in Advance!!
Also later in other file called tracktrees.php i am using this line to print the dropdown choosen value, but getting warning,
$specresult = mysql_query("SELECT * FROM Species_master WHERE species_id=".$_POST["data1"]");
echo "$specresult";
Thanks once again!!
Displaying dropdown list from DB table & printing selected
Moderator: General Moderators
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
Re: Displaying dropdown list from DB table & printing selected
You're not ending your first quotation.Code: Select all
$specresult = mysql_query("SELECT * FROM Species_master WHERE species_id=".$_POST["data1"]");
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
Re: Displaying dropdown list from DB table & printing selected
Thank you very much aravona!!aravona wrote:You're not ending your first quotation.Code: Select all
$specresult = mysql_query("SELECT * FROM Species_master WHERE species_id=".$_POST["data1"]");
one more help may be again this could be easier for you but as a new student in php world I feel it slightly difficult,
I have one home template(complete homepage image), which having rectangular boxses , i used <map> their for redirecting to new file, it's working fine too, but now there is one more rectangular box which onclick has to a dropdown list(coming from a db table where user_id=...)
This code is working fine:
$sql = mysql_query("SELECT tree_nickname FROM user_tree_table WHERE user_id=81");
while($row = mysql_fetch_assoc($sql))
{
$data1 .= "<option value='{$row['tree_nickname']}'>{$row['tree_nickname']}</option>";
}
?>
Please suggest how i can achieve it.Thanks in Advance!!
Re: Displaying dropdown list from DB table & printing selected
Erm, little lost this time. If the codes working what is it you are trying to achieve?
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
Re: Displaying dropdown list from DB table & printing selected
Sorry I think I could not explain it properly, Simply i wanted to ask how i can link it using <map> tag in my template.As of now it is redirecting to a new php file having dropdown instead of in the same page reactangular area.aravona wrote:Erm, little lost this time. If the codes working what is it you are trying to achieve?
Thanks once again!!