Jump to content

[SOLVED] Quick Question


paulman888888

Recommended Posts

This is the code for my view scores

<?php
// Get sort method
$sort = isset($_GET['order']) ? mysql_real_escape_string($_GET['order']) : 'score';
// Get all the data from the "myscore2" table
$result = mysql_query("SELECT * FROM myscore2 ORDER BY `{$sort}` DESC");
//the rest is not important

How could i add a AESC or DESC link

Link to comment
https://forums.phpfreaks.com/topic/108718-solved-quick-question/
Share on other sites

use a get, and send it ASC or DESC

 

$sort = $_GET['sort'];
$query = 'SELECT * FROM myscore2 ';
switch($sort){
    case 'ASC':
        $query .= 'ORDER BY score ASC';
    break;
    case 'DESC':
        $query .= 'ORDER BY score DESC';
    break;
}
$sql = mysql_query($query);

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.