You are here: Re: Populating <options> tag with SQL data? « PHP Programming Language « IT news, forums, messages
Re: Populating <options> tag with SQL data?

Posted by cresh on 05/03/07 18:40

Just in case anyone else needs this type of code, here is my small
example, thanks to the help received here. The reference to
"require.php" is where I store my database and server information,
such as dbase name, user, password, etc.

Thanks again for the assistance, it works great.

Cresh

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Retrieve Information</title>
</head>
<body>
<? require('require.php');
$link = mysql_connect($dbasehost, $dbaseuser, $dbasepass);
if (!$link) {
die('Could not connect to the database. Error is: ' .
mysql_error());
}
mysql_select_db($dbasename);
?>
<form name"myform" action="file.php" method="post">
<p>Make a selection: <select name="program">

<?
$r = mysql_query("select information from info");
while($row = mysql_fetch_assoc($r))
{
echo "<option
value='{$row['information']}'>{$row['information']}</option>";
}
?>
</select></form>
</body>
</html>

 

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

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