Hello,
I tried to build a drop down menu that its content is a MySQL data. Unfortunately it does not work.
Can anyone tell me what the problem is?
Script (HTML file):
<html>
<head>
<title> Untitled </title>
</head>
<body>
<tr>
<td height="86"></td>
<td colspan="4" rowspan="2" valign="top"><select name="spec[]" size="6" multiple id="spec">
<option value="All" selected>All
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'car';
$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 species FROM list";
$result = mysql_query($query);
if(!$result) die(mysql_error());
echo "<select name=\"species\">\n";
echo "<option value=\"\"> </option>\n";
while($row = mysql_fetch_array($result))
{
echo "<option value=\"$row[species]\">$row[species]</option>\n";
}
echo "</select>\n";
echo "<P><input type=\"submit\" value=\"submit\"></p>\n";
?>
</select>
</select>
</tr>
</body>
</html>
I tried to build a drop down menu that its content is a MySQL data. Unfortunately it does not work.
Can anyone tell me what the problem is?
Script (HTML file):
<html>
<head>
<title> Untitled </title>
</head>
<body>
<tr>
<td height="86"></td>
<td colspan="4" rowspan="2" valign="top"><select name="spec[]" size="6" multiple id="spec">
<option value="All" selected>All
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'car';
$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 species FROM list";
$result = mysql_query($query);
if(!$result) die(mysql_error());
echo "<select name=\"species\">\n";
echo "<option value=\"\"> </option>\n";
while($row = mysql_fetch_array($result))
{
echo "<option value=\"$row[species]\">$row[species]</option>\n";
}
echo "</select>\n";
echo "<P><input type=\"submit\" value=\"submit\"></p>\n";
?>
</select>
</select>
</tr>
</body>
</html>