Simple and quick php Querystring
If you need to pass one single $var from page to page, this would be the most simple of ways to do it using php. Which also results in very little code for handling it.First create the url with the var attached. As so.
http://www.yoursite.com?querystring
Notice there's no assignment using an equal sign as you'd normally do.(Like this)
http://www.yoursite.com?str=querystring
Now we have to read the query string upon page change.
All you have to write is.
$var = $_SERVER['QUERY_STRING'];
That's pretty much it. No parsing of the string returned.
You could also use this in other ways, as with if/else blocks and switch/case statements.
Sample if/else block:
<?php
if ($_SERVER['QUERY_STRING'] == "nhl") {
doThis();
}
elseif ($_SERVER['QUERY_STRING'] == "querystring") {
doThat();
}
?>
Sample switch/case block:
<?php
switch($_SERVER['QUERY_STRING']) {
case 'nhl':
doThis();
break;
case 'querystring':
doThat();
break;
default:
doSomething();
}
?>
Of course as I mentioned at the beginning of this article, this method for query strings is only useful for passing one value, which results in not having to parse the returned string with extra code and processing times.
This way of retrieving a query string can also be applied to Javascript in much the same manner, as I wrote about previously and can be read about here.
$var = $_SERVER['QUERY_STRING'];
That's pretty much it. No parsing of the string returned.
You could also use this in other ways, as with if/else blocks and switch/case statements.
Sample if/else block:
<?php
if ($_SERVER['QUERY_STRING'] == "nhl") {
doThis();
}
elseif ($_SERVER['QUERY_STRING'] == "querystring") {
doThat();
}
?>
Sample switch/case block:
<?php
switch($_SERVER['QUERY_STRING']) {
case 'nhl':
doThis();
break;
case 'querystring':
doThat();
break;
default:
doSomething();
}
?>
Of course as I mentioned at the beginning of this article, this method for query strings is only useful for passing one value, which results in not having to parse the returned string with extra code and processing times.
This way of retrieving a query string can also be applied to Javascript in much the same manner, as I wrote about previously and can be read about here.
2whoa.com - NEW!!
Home
jQuery
Javascript
Archives
MLB Wallpapers
NFL Wallpapers
NBA Wallpapers
NHL Wallpapers
Flames Wallpaper
Watch Live Games!
NHL
NBA
Soccer
NFL
and more..
BMW, Toyota, Volvo, Saab, Audi, Nissan Mercedes, Volvo, Nissan,Volvo Volvo Volvo Honda, Acura, Honda, Acura Forerunner, SUV, Volvo, Mercedes, Toyota
Volvo, Toyota, Volvo, Saab, Audi, Nissan Mercedes, Volvo, Nissan,Volvo Volvo Volvo Honda, Acura, Honda, Acura Forerunner, SUV, Volvo, Mercedes, Toyota
Home
jQuery
Javascript
Archives
MLB Wallpapers
NFL Wallpapers
NBA Wallpapers
NHL Wallpapers
Flames Wallpaper
Watch Live Games!
NHL
NBA
Soccer
NFL
and more..
BMW, Toyota, Volvo, Saab, Audi, Nissan Mercedes, Volvo, Nissan,Volvo Volvo Volvo Honda, Acura, Honda, Acura Forerunner, SUV, Volvo, Mercedes, Toyota
Volvo, Toyota, Volvo, Saab, Audi, Nissan Mercedes, Volvo, Nissan,Volvo Volvo Volvo Honda, Acura, Honda, Acura Forerunner, SUV, Volvo, Mercedes, Toyota



Leave a comment
Volvo, Toyota, Volvo, Saab, Audi, Nissan Mercedes, Volvo, Nissan, Honda,Volvo Volvo Volvo Acura, Honda, Acura Forerunner, SUV, Volvo, Mercedes, Toyota