Revision: 8638
Updated Code
at October 1, 2008 11:00 by simplistik
Updated Code
<?php /** * Name: Preserve and update/rebuild query string<br> * @param Example: * Example URL: http://www.site.com/?category=foo&order=desc&page=2 * * <a href="<?php echo queryString('order','asc'); ?>">Order ASC</a> * * Output HTML: <a href="?category=foo&order=asc&page=2">Order ASC</a> * Output URL: http://www.site.com/?category=foo&order=asc&page=2 * * Not http://www.site.com/?category=foo&order=desc&page=2&order=asc */ function queryString($str,$val) { $queryString = array(); $queryString = $_GET; $queryString[$str] = $val; $queryString = "?".htmlspecialchars(http_build_query($queryString),ENT_QUOTES); return $queryString; } ?>
Revision: 8637
Updated Code
at October 1, 2008 10:56 by simplistik
Updated Code
<?php /** * Name: Preserve and update/rebuild query string<br> * @param Example: * Example URL: http://www.site.com/?category=foo&order=desc&page=2 * * <a href="<?php echo queryString('order','asc'); ?>">Order ASC</a> * * Output HTML: <a href="?category=foo&order=asc&page=2">Order ASC</a> * Output URL: http://www.site.com/?category=foo&order=asc&page=2 * * Not http://www.site.com/?category=foo&order=desc&page=2&order=asc */ function queryString($str,$val) { $queryString = array(); $queryString = $_GET; $queryString[$str] = $val; $queryString = "?".htmlspecialchars(http_build_query($queryString)); return $queryString; } ?>
Revision: 8636
Updated Code
at October 1, 2008 10:54 by simplistik
Updated Code
<?php /** * Name: Preserve and update/rebuild query string<br> * @param Example: * Example URL: http://www.site.com/?category=foo&order=desc&page=2 * * <a href="<?php echo queryString('order','asc'); ?>">Order ASC</a> * * Output HTML: <a href="?category=foo&order=asc&page=2">Order ASC</a> * Output URL: http://www.site.com/?category=foo&order=asc&page=2 * * Not http://www.site.com/?category=foo&order=desc&page=2&order=asc */ function queryString($str,$val) { $queryString = array(); $queryString = $_GET; $queryString[$str] = $val; $queryString = $_SERVER['REQUEST_URI']."?".htmlspecialchars(http_build_query($queryString)); return $queryString; } ?>
Revision: 8635
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 1, 2008 10:45 by simplistik
Initial Code
<?php /** * Name: Preserve and update/rebuild query string<br> * @param Example: * Example URL: http://www.site.com/?category=foo&order=desc&page=2 * * <a href="<?php echo queryString('order','asc'); ?>">Order ASC</a> * * Output HTML: <a href="?category=foo&order=asc&page=2">Order ASC</a> * Output URL: http://www.site.com/?category=foo&order=asc&page=2 * * Not http://www.site.com/?category=foo&order=desc&page=2&order=asc */ function queryString($str,$val) { $queryString = array(); $queryString = $_GET; $queryString[$str] = $val; $queryString = $_SEVER['REQUEST_URI']."?".htmlspecialchars(http_build_query($queryString)); return $queryString; } ?>
Initial URL
Initial Description
Allows you preserve and update a query string and it's existing values easily, instead of constantly appending the new value to the end of the query string
Initial Title
Preserve & update/rebuild query string
Initial Tags
query, update
Initial Language
PHP