woodplease Posted December 1, 2009 Share Posted December 1, 2009 Hi, i've got a read the contents of a database to a page, and i want to create an 'order by' function so that i can order the contents by price, or alphabetically. I know the sql to order them by, i just dont know how to create the links( like you'd see on amazon etc). It doesnt have to be a drop down box, it could be just links. This is my code for connecting to a databse, and i've already ordered it by price, its just i want it to display without being ordered, and then you click on a link to order it <?php $conn = pg_connect("host=database.dcs.****.co.uk port=5432 dbname=***** user=**** password=**********"); $res = pg_query ($conn, "SELECT title,platform,description,price FROM CSGames order by price" ); echo "<table border='1' id='gamelist'>"; echo "<tr><th>Title</th><th>Platform</th><th>Description</th><th>Price</th></tr>"; while ($a = pg_fetch_row($res)) { echo "<tr>"; for ($j = 0; $j < pg_num_fields($res); $j++) { echo "<td>" . $a[$j] . "</td>"; } echo "</tr>"; } echo "</table>\n"; ?> Any help would be great Thanks Link to comment https://forums.phpfreaks.com/topic/183621-create-an-order-by/ Share on other sites More sharing options...
rajivgonsalves Posted December 1, 2009 Share Posted December 1, 2009 why don't you pass your order by in the GET or POST and you can retrieve that and put it in your SQL Link to comment https://forums.phpfreaks.com/topic/183621-create-an-order-by/#findComment-969168 Share on other sites More sharing options...
woodplease Posted December 1, 2009 Author Share Posted December 1, 2009 sorry, i'm not sure what you mean, i'm quite new to php. could you explain a bit more Link to comment https://forums.phpfreaks.com/topic/183621-create-an-order-by/#findComment-969177 Share on other sites More sharing options...
rajivgonsalves Posted December 1, 2009 Share Posted December 1, 2009 this link might help http://php.net/manual/en/reserved.variables.get.php Link to comment https://forums.phpfreaks.com/topic/183621-create-an-order-by/#findComment-969180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.