Ok, I'll try to explain it again.
You have a script that prints the list, let's call it 'printlist.php'
What you want to do is order that list by whatever you want.
That means you have to have a way of letting printlist.php know what it should order the list by.
The simplest method is by passing a parameter in the URL:
http://www.some.host/printlist.php?orderby=name
http://www.some.host/printlist.php?orderby=date
http://www.some.host/printlist.php?orderby=phone
The simplest way of sending that parameneter is by putting the complete link into an HREF:
<a href="printlist.php?orderby=name>Name</a>
and you can put that at the top of the 'name' column.
Then in printlist.php you build your query depending on what's in $orderby:
$sQuery = "SELECT * FROM table";
switch($orderby)
{
case 'name':
$sQuery .= " ORDER BY name ASC";
case 'date':
$sQuery .= " ORDER BY date ASC";
case 'phone':
$sQuery .= " ORDER BY phone ASC";
}
// Execute query and print the list
But, this setting is 'one-time-only'. It will not be remembered when the person returns to the list after browsing somewhere else. If you want it to be remembered, you can use cookies or sessions.