Given the following URL:
http://shadow.econ.duke.edu/working_papers.php?order=title&dir=ASC
They call the variables out of the GET array and use them in their query.... So their query is something like:
$query = "SELECT * FROM thetable ORDER BY ".$_GET['order']." ".$_GET['dir']";
// So echoing $query would echo something like:
// SELECT * FROM thetable ORDER BY title ASC
There are many ways to do this, but these are the basics...