affluent980 Posted January 29, 2009 Share Posted January 29, 2009 I have a table that tracks collects lead information like name email and phone number. it starts with the LeadID, which is primary. When the results are displayed, they are in a wierd order that i don't understand. I would like it to sort the displayed results by the LeadID, so they are in order. Please help! Here is the code as is: <?php echo "<table border='1'> <tr> <th>LeadID</th> <th>CID</th> <th>Category</th> <th>Name</th> <th>Email</th> <th>Phone</th> <th>Date</th> <th>Time</th> <th>Keyword</th> <th>Good Lead</th> <th>Bad Lead</th> <th>Closed</th> <th>Revenue</th> </tr>"; $result = mysql_query("SELECT * FROM Leads WHERE CID='$session->username'"); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['LeadID'] . "</td>"; echo "<td>" . $row['CID'] . "</td>"; echo "<td>" . $row['Category'] . "</td>"; echo "<td>" . $row['Name'] . "</td>"; echo "<td>" . $row['Email'] . "</td>"; echo "<td>" . $row['Phone'] . "</td>"; echo "<td>" . $row['Date'] . "</td>"; echo "<td>" . $row['Time'] . "</td>"; echo "<td>" . $row['Keyword'] . "</td>"; echo "<td>" . $row['More'] . "</td>"; echo "<td>" . $row['Less'] . "</td>"; echo "<td>" . $row['Closed'] . "</td>"; echo "<td>" . $row['Revenue'] . "</td>"; echo "</tr>"; } echo "</table>"; } /* Link back to main */ echo "<br>Back To [<a href=\"main.php\">Main</a>]<br>"; ?> Quote Link to comment Share on other sites More sharing options...
printf Posted January 29, 2009 Share Posted January 29, 2009 // order by lowest to highest $result = mysql_query ( "SELECT * FROM Leads WHERE CID='" . $session->username . "' ORDER BY LeadID;" ); // order by highest to lowest $result = mysql_query ( "SELECT * FROM Leads WHERE CID='" . $session->username . "' ORDER BY LeadID DESC;" ); Quote Link to comment Share on other sites More sharing options...
affluent980 Posted January 29, 2009 Author Share Posted January 29, 2009 That worked great! Thanks!!! Your the best! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.