Hello,
As a newbie in PHP I try to build a drop down menu which its content will be retrieve from my simple MYSQL database.
The following HTML file combine PHP script that get the database content and put it in the menu:
<HTML>
<HEAD>
<TITLE>show car</TITLE>
</HEAD>
<BODY>
<FORM action="http://localhost/view.php" method="GET">
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'DVD';
$table = 'list';
$link = mysql_connect($host,$user,$pass);
if(!$link) die(mysql_error());
$select = mysql_select_db($db);
if(!$select) die(mysql_error());
$query = "SELECT name FROM list";
$result = mysql_query($query);
if(!$result) die(mysql_error());
print "search:<br>\n";
print "<select name=\"nam\">\n";
print "<option value=\"\"> </option>\n";
while($row = mysql_fetch_array($result))
{
print "<option value=\"$row[name]\">$row[name]</option>\n";
}
print "</select>\n";
?>
<input type="submit" value="submit">
</FORM>
</BODY>
</HTML>
But it does not work, can anyone help me PLZ.
Thank you all.