PHP Dropdown menu [closed]
- by rShetty
<br><h2>Select a Tag</h2></br>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("portal", $con);
$query = "SELECT tag_name FROM tags";
$result = mysql_query($query);
?>
<select name="tag_name" id="abc">
<option size=30 selected>Select</option>
<?php
while($array = mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $array['tag_name'];?>"><?php echo $array['tag_name'];?>
</option>
<?php
}
?>
</select> <br><br>
This is a snippet of code for getting the dropdown menu in the page.
I have a database named portal and table named tags with tag_name as the attribute.
Do help me to find the error in the program.
I am not getting the tag_names in the dropdown menu