You are here: Re: PLEASE HELP ME ($20 REWARD!!) PHP(v5.0.4)/MySQL(v4.1.14) Problem. Need Basic Drop-down menu populated by 1 column from MySql « PHP Programming Language « IT news, forums, messages
Re: PLEASE HELP ME ($20 REWARD!!) PHP(v5.0.4)/MySQL(v4.1.14) Problem. Need Basic Drop-down menu populated by 1 column from MySql

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация