|
Posted by NC on 01/26/06 07:59
snowsong1 wrote:
>
> I have a database called rotary_pizza_db and a table called greeks
> The table greeks contains the column called house
> I simply want a page with ONE drop down menu that takes the house names
> from the mysql database and uses them to populate a drop-down menu with
> choices, and sends the variable as house (if possible)
// Connecting to the database server
$link = mysql_connect('host', 'user', 'password')
or die('Could not connect: ' . mysql_error());
// Selecting database
mysql_select_db('rotary_pizza_db')
or die('Could not select database');
// Performing SQL query
$result = mysql_query('SELECT house FROM greeks')
or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<form action='#'>\r\n<select name=house>\r\n";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
$house = $line[0];
echo " <option value=$house>$house\r\n";
}
echo "</select>\r\n <input type=submit value=Send>\r\n</form>\r\n";
That's it, really...
Cheers,
NC
[Back to original message]
|