Note Submitter: trevor
----
I needed to do the exact same thing as jwl007 (sort by clicking links) but I needed it to append the variable to the query string if it didn't already exist. Here's the function I'm using:
<?php
function setGetVar($var, $val){
$request_uri = $_SERVER["REQUEST_URI"];
if(strstr($request_uri, $var)) {
return preg_replace("/$var=[\\d\\w]*/", "$var=$val", $request_uri);
} elseif(strstr($request_uri, "?")) {
return $request_uri . "&" . $var . "=" . $val;
} else {
return $request_uri . "?" . $var . "=" . $val;
}
}
?>
<a href="<?php echo setGetVar("orderby", "lname"); ?>">Sort by Last Name</a>
<a href="<?php echo setGetVar("orderby", "fname"); ?>">Sort by First Name</a>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.