hi,
im creating a very simple web shop for some practice... im connected to my database and showing the table fine, what i want now is to add a HTML button that when clicked sorts the table in order of price.
I can do this by directing and sorting the table on a new page, but i was wondering if it could be done on the same page (maybe with a function or something...)
Heres my code for printing the table...
<?php
$conn = pg_connect("host=************* port=**** dbname=******** user=******* password=*******");
$res = pg_query ($conn, "select * from CSGames");
echo "<table border='1'>";
echo "<th>Title</th><th>Description</th><th>Price (£)</th><th>Select</th>";
while ($a = pg_fetch_array ($res))
{
echo "<tr>";
echo "<td>" . $a["title"] . "</td>";
echo "<td>" . $a["description"]. "</td>";
echo "<td>" . $a["price"] . "</td>";
echo("<td><input type='checkbox' name='select' size='20'></td>");
}
?>
PHP Query
Moderator: General Moderators
Re: PHP Query
I suppose the easiest option would be to resubmit the query with ORDER BY price ASC attached. Leaving the form action blank or pointing it to the current page will reload the page.