Reputation: 5672
Code for example:
<?php
$sql = "SELECT * FROM `table_name` ORDER BY `first_name` DESC";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) < 1) {
echo "Database is empty";
} else {
while ($details = mysql_fetch_array($result)) {
?>
Here would be various calls for $details amongst HTML, like:
<a href="<?php echo $details[8]; ?>">Link</a>
And close it with:
<?php
}
}
?>
What I'd like to do is be able to change the sql sort order without reloading/changing the page. Any ideas?
Upvotes: 0
Views: 626
Reputation: 1870
If you're a novice, you can try an off-the-shelf product like this:
Upvotes: 2
Reputation: 4766
Once the page is rendered the PHP is finished, resulting in a page of 100% HTML. If you want to refresh without reloading then you would have to have a PHP file that takes an argument and conducts this SELECT. Then, based on which link the user clicks, you would use JavaScript to conduct an Ajax request. And then refresh the contents of the page based on the Ajax return.
Upvotes: 0
Reputation: 855
Once you have returned the result set to your application, you can re-sort it there. No need to issue a new query to change the sort-order, though I suppose you could.
Upvotes: 2