Hello
I'm new to PHP/programming
However, I have somehow managed to make a script that will pull info from a mysql table/column and use that to populate a dropdown menu. It works perfect for what I'm doing ... but I'd like to take it a stage further. If for example it gets the data from a column of last/surnames ... I could have several entries for a surname. What I'd like it to do is 'filter out' any multiple entries and display the name once only. It took me a long to time to suss the script as it is ... so please ne gentle with any explinations
Here's what I've done and I hope you can help:
<?
mysql_connect ("mysql.address.com", "dbname", "password");
mysql_select_db ("dbname");
$query = "select * from students";
$result = mysql_query($query);
$num = mysql_numrows($result);
echo "<font face=\"Arial\" color=\"red\">Students:</font><br>";
echo "<select name=\"Student\"student>";
echo "<option value='' selected>select the last name</option>";
/Dynamically generate drop-down list/
$i=0;
while ($i<$num):
$hello = mysql_result($result,$i, "lastname");
echo "<option value='$hello'>$hello</option>";
$i++;
endwhile;
echo "</select><p>";
?>