Jump to content

create an 'order by'


woodplease

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.