Jump to content
Sign in to follow this  
ohsnyder

Sorting output problem

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);?>

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.
Thank you very much! Removed the single quotes and it works fine now.

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...