note 68723 added to reserved.variables
| From: | trevor at osu1 dot php dot net | Date: | Tue, 08 Aug 2006 17:49:45 +0000 |
| Subject: | note 68723 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115670@lists.php.net to get a copy of this message | ||
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>
----
Server IP: 66.163.161.117
Probable Submitter: 63.226.97.170
----
X-Spam-Status: No, hits=4.0 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_20_30,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit -- https://master.php.net/note/edit/68723
Del: integrated -- https://master.php.net/note/delete/68723/integrated
Del: useless -- https://master.php.net/note/delete/68723/useless
Del: bad code -- https://master.php.net/note/delete/68723/bad+code
Del: spam -- https://master.php.net/note/delete/68723/spam
Del: non-english -- https://master.php.net/note/delete/68723/non-english
Del: in docs -- https://master.php.net/note/delete/68723/in+docs
Del: other reasons-- https://master.php.net/note/delete/68723
Reject -- https://master.php.net/note/reject/68723
Search -- https://master.php.net/manage/user-notes.php