Jump to content

Drop Down Menu Using DB Records


refiking

Recommended Posts

I am trying to place all the items from the sql query in a drop down menu.  What is the correct way to code this? 

 

Here is what I have:

 

$league = mysql_query("SELECT * FROM dlg WHERE lid = '$lid'")or die(mysql_error());
while ($row3 = mysql_fetch_array($league)){
$dlg = $row3['lname'];
?>
<form action="index.php" method="post">
<select name="lid">
<option value="<?echo $lid.'>'.$dlg.'"';?></option>
</select>
<input type="Submit" value="Select League">
</form>

Link to comment
https://forums.phpfreaks.com/topic/99233-drop-down-menu-using-db-records/
Share on other sites

<form action="index.php" method="post">
<select name="lid">
<?php
if ($league = mysql_query("SELECT * FROM dlg WHERE lid = '$lid'")) {
  if (mysql_num_rows($legue)) {
    while ($row3 = mysql_fetch_array($league)){
      $dlg = $row3['lname'];
      echo "  <option value=\"$lid\">$dlg</option>";
    }
  }
}
?>
</select>
<input type="Submit" value="Select League">
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.