Jump to content

Sorting output problem


ohsnyder

Recommended Posts

an someone tell me why this code isNOT sorting the lname output listing ? <?php include("/home/mdwvo/public_html/aabees.org/password_protect.php"); ?> <?php $con = mysql_connect("localhost","mdwvo_aaba","pwpwpwpwpw");if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mdwvo_aaba", $con); $result = mysql_query("SELECT * FROM members WHERE deleted = 'Yes' ORDER BY 'lname' "); Echo "<table size=50%>"; while($row = mysql_fetch_array($result)) { Echo "<tr><td>".$row['id'] . "</td></tr> <tr><td>".$row['fname']." ".$row['lname']."</td><td align=left> Date Joined - ".$row['joined'] . "</td></tr> <tr><td>".$row['street'] . "</td><td align=left> Dues Paid Through - ".$row['paid'] . "</td></tr> <tr><td align=left>".$row['city'] . ", ".$row['state'] . " ".$row['zip'] . "</td><td align=left> Phone - ".$row['phone'] . "</td></tr> <tr><td> </td><td align=left> Email - ".$row['email'] . "</td></tr>"; } Echo "</table>"; mysql_close($con);?>

Link to comment
Share on other sites

it should be sorting them ASC (ascending) by default. Your other option is DESC (descending).http://www.w3schools...sql_orderby.asp If there was some other kind of sorting you were expecting, you'll have to explain that. edit: ideally, provide the actual output you are seeing, vs. what you want to see

Edited by thescientist
Link to comment
Share on other sites

You have lname in quotes, remove the quotes. You are telling it to sort by the text "lname" (which is the same for every record) instead of the lname field.
doh :blush:
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...