Mornin'. Try this:
<?php
$sort = $_GET['sort'];
if(!isset($sort)){
$sort = 0;
echo "<br/ >This is $sort<br /><br /><br />";
}else{
$sort = $sort;
}
echo "<a href='test.php?sort=1'>1</a><br />
<a href='test.php?sort=2'>2</a><br />
<a href='test.php?sort=3'>3</a><br />";
?>
What this does is tells your script to get the value of sort from the URL. If the URL was visited by any link other than the ones you specify down below, the value will be set to 0. But, if they click on the links below, sort will be the number associated with the link. Keep in mind that a user could simply type in a url like test.php?sort=120398402342 and then sort would be set to that ridiculously long number. If you want to avoid that, and have a predefined number of sort numbers you could do this:
<?php
$sort = $_GET['sort'];
$numbers = array("1","2","3");
if(!isset($sort) || !in_array($sort, $numbers)){
$sort = 0;
echo "<br />This is $sort<br /><br /><br />";
}else{
$sort = $sort;
}
echo "<a href='test.php?sort=1'>1</a><br />
<a href='test.php?sort=2'>2</a><br />
<a href='test.php?sort=3'>3</a><br />";
?>