Dear all
I want to populate a few drop down boxes using PHP. However i have tried many examples i found from the web but the select box does not get any values. Below i have one example i have tried.
**********************************************
<?php
$link = mysql_connect("localhost", "root", "password") or die("Could not connect: " . mysql_error());
mysql_select_db('db', $link) or die (mysql_error());
$query = "SELECT last_name FROM main_author order by last_name";
$result = mysql_query($query) or die("Couldnt' execute query.");
$num = mysql_numrows($result);
?>
<html>
<body>
<form name="test" id="test" method="post">
<select value="" size="1" name="test2">
<option>all</option>
<? $i=0; while ($i<$num)
{$authors=mysql_result($result,$i,"last_name");
echo "<option>$authors</option>";
$++; }
mysql_close(); ?>
</select>
</body>
</html>
********************************************
any suggestions would be more than appreciated
Many thnx
Cheers