Matthew1980 - 9:38 pm on Dec 22, 2011 (gmt 0)
Hi there Gilead,
You're so close! Order by is the correct syntax to use, and this will sort the chosen field (in this case FirstName) into alphabetical order either ASCending or DESCending, so you'll need to alter that variable accordingly:-
$query = "SELECT `contactid`, `firstname`, `lastname` FROM `".$table_name."` ORDER BY `firstname` DESC";
$sql = mysql_query($query);
echo "<select name=\"ContactID\">";
$id = htmlentities($row['contactid']);
$firstname = htmlentities($row['firstname']);
$lastname = htmlentities($row['lastname']);
echo "<option value = "\".$id."\" >";
echo $firstname." ".$lastname; //optional space between the names
I've reformatted the way the concatenations were done so that everything is uniform - good coding practice..
Hopefully if you run this now you'll get the results as you're expecting.