ohsnyder Posted November 5, 2012 Share Posted November 5, 2012 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 More sharing options...
thescientist Posted November 5, 2012 Share Posted November 5, 2012 (edited) 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 November 5, 2012 by thescientist Link to comment Share on other sites More sharing options...
justsomeguy Posted November 5, 2012 Share Posted November 5, 2012 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. Link to comment Share on other sites More sharing options...
ohsnyder Posted November 5, 2012 Author Share Posted November 5, 2012 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. Link to comment Share on other sites More sharing options...
thescientist Posted November 5, 2012 Share Posted November 5, 2012 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now