It's quite possible that this is impossible.. but here goes...

I have some personnel data that is being reported in a table and in that table I have a field that holds a person's "title". Let's say the returned "title" results are "President", "Vice President", "Assistant To The President" and "Assistant to the Vice President". There are not more than four of them. Does anybody have any idea if I could sort the returned results based on the above hierarchy - which is not alphabetical?

Here is my beginner's code:

echo "<center>\n";
echo "<H2>Roster</H2>\n";
echo "<table border='1'>
   <tr>
<th>Title</th>
<th>First Name</th>
<th>Last Name</th>

</tr>";

if (mysql_num_rows($query)) {
    while ($row = mysql_fetch_array($query)) {
$variable1=$row["title"];
$variable2=$row["firstname"];
$variable3=$row["lastname"];
       
//table layout
       
print("<tr>");
echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
echo "<td class=\"td_id\">$variable1</td>\n";
echo "<td class=\"td_id\">$variable2</td>\n";
echo "<td class=\"td_id\">$variable3</td>\n";
print("</tr>");

Thanks for looking at it!

Sorting non-alphabetical/non-numerical records is not possible AFAIK. But you can have one more field of type int in the table, eg, type. You can enter the order of title, then sort by type !

SOLVED.
Took your advice and all is well. thanks.

This question has already been answered. Start a new discussion instead.