Jump to content

Dropdown generated from Database information


Ryflex

Recommended Posts

Hi all,

 

Does anyone know if it's possible to generate a dropdown list filled with database information.

I use the following to get the information from the database:

$query                      = "SELECT Name
                               FROM city
                               WHERE member_ID = '$member_ID'";
$result                     = mysql_query($query)
                              or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
     echo $row['Name'] . '<br>';
}

 

Thnx Ryflex

You are doing it now pretty much just forgetting to add the dropdown... try this:

 

<?php
$query = "SELECT NameFROM city WHERE member_ID = '$member_ID'";
$result = mysql_query($query) or die(mysql_error());

echo '<select name="dropdown">';
while($row = mysql_fetch_assoc($result)){
     echo '<option>'.$row['Name'] . '</option><br>';
}
echo '</select>';
?>

Hi all,

 

A little addition to my question...

Is it possible to make the dropdown menu in a way that when I click one of the entries it automaticaly uses that value as a submit.

So if I click value 2 the page reloads and $_post the value 2.

 

Thnx Ryflex

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.