0

Hello everybody. I'm pretty new to PHP and mysql. I made a mysql database table: Election_Table
One of the fields in there is elect_title, and the primary key is ID

I am trying to make a drop down menu that has the names of all the names of the elections (elect_title) in this table. I also need to pass whatever election the user chose to link with buttons with different functions. Say if I have a 'Status' button, I will choose a election from the drop down and click 'Status' button to see status (I will have a function called showStatus on this file that will handle this). Here's what i have so far: Nothing shows up

<?

$sql=mysql_query("SELECT elect_title FROM Election_Table") or die("Cannot retrieve names from election table");

$result=mysql_query($sql);

print($result);
$options="";

while ($row=mysql_fetch_array($result)) {

  $id=$row["elect_title"];
  $options.="<OPTION VALUE=\"$elect_title\">";
}

?>
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by CFROG
0

Try this out instead.

<?
 
$sql=mysql_query("SELECT elect_title FROM Election_Table") or die("Cannot retrieve names from election table");
 
$result=mysql_query($sql);
 
print($result);
$options="";
 
while ($row=mysql_fetch_array($result)) {
 
  $id=$row["elect_title"];
  $options.="<OPTION VALUE=\"$id\">";
}
?>
<select name="elect_title">
<?=$options?>
</option>
</select>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.