note 68723 deleted from reserved.variables by felipe

From: Date: Sun, 30 Dec 2007 18:25:46 +0000
Subject: note 68723 deleted from reserved.variables by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134357@lists.php.net to get a copy of this message
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>

« previous php.notes (#134357) next »