Bifter Posted October 2, 2008 Share Posted October 2, 2008 Hi All, Hopefuly somone can point me in the right direction on this. Basicly I need a way of ordering the results of a SQL query by date in a html table: <?php mysql_select_db("ipendpoi_Purchase", $conn); $result = mysql_query("SELECT * FROM po"); echo "<table width='100%' border='1'> <tr> <th>Date</th> <th>PO Number</th> <th>Requester</th> <th>Amount</th> <th>Vendor</th> <th>Department</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . "<a href=\"upload_directory/Purchase-Order-" . $row['number'] . ".pdf\">" . $row['number'] . "</a>" . "</td>"; echo "<td>" . $row['requester'] . "</td>"; echo "<td>" . "£" . $row['amount'] . "</td>"; echo "<td>" . $row['vendor'] . "</td>"; echo "<td>" . $row['department'] . "</td>"; echo "</tr>"; } echo "</table>";mysql_close($conn); ?> Thanks for looking. Link to comment https://forums.phpfreaks.com/topic/126731-solved-ordering-sql-results-by-date/ Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 $result = mysql_query("SELECT * FROM po ORDER BY date"); or $result = mysql_query("SELECT * FROM po ORDER BY date DESC"); Whatever tickles your fancy! Link to comment https://forums.phpfreaks.com/topic/126731-solved-ordering-sql-results-by-date/#findComment-655478 Share on other sites More sharing options...
Bifter Posted October 2, 2008 Author Share Posted October 2, 2008 Great stuff, knew it had to be simple! Thanks. Link to comment https://forums.phpfreaks.com/topic/126731-solved-ordering-sql-results-by-date/#findComment-655480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.