/    Sign up×
Community /Pin to ProfileBookmark

Passing Variables through the url

Hi, to explain my circumstance in full i am passing a couple sometimes 3 variables through the url i.e

[code=php]
blah.php?TypeM=Monophonic
[/code]

I need to be able to rather than add to the url i.e use the

[code=php]
$_SERVER[“QUERY_STRING”]
[/code]

I need to be able to replace that current variable i.e TypeM

now my full URL may look like this

?selection=Ringtones&Page=4&TypeM=Monophonic now i need to be able say in this URL if i went to page 5 i need it to replace Page=4 with Page=5 RATHER than having this
?selection=Ringtones&Page=4&TypeM=Monophonic&Page=5

I get the above by the $_SERVER[“QUERY_STRING”]

but i just want to replace the current variable.

Click here for an example. Please click on next page and then monophonic and then polyphonic and then another page. I want to advoid this as it causes me lots of problems

[url]http://www.ringtones2logos.co.uk/main/ringtones/ringtones.php?selection=Ringtones[/url]

Your help is great
Adam

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Daniel_TSep 20.2004 — [code=php]if(isset($_GET['Page']))
{
$newstring = preg_replace("/Page=[0-9]+/i", "Page=" . $newpagenumber, $_SERVER['QUERY_STRING']);
}
else
{
$newstring = $_SERVER['QUERY_STRING'] . "&Page=" . $newpagenumber;
}[/code]
Just make $newpagenumber the number of page you want the new querystring to have.
Copy linkTweet thisAlerts:
@endersshadowSep 20.2004 — <?
$selection=$_GET['selection'];
$typem=$_GET['TypeM'];
$page=$_GET['Page'];
if($page>0)
{
$nextpage=$page+1;
}
else
{
$page=1;
$nextpage=$page+1;
}
$myurl="blah.php?selection=".$selection."&TypeM=".$typem."&Page=".$nextpage;
echo "<a href="".$myurl."">Next</a>";
?>
Copy linkTweet thisAlerts:
@k0r54authorSep 20.2004 — DAMIT, sometimes i just dont think

look what i done to get it working :@

:mad:

HOW SIMPLE

[code=php]
if (empty($TypeM)){
$print_query = "?selection=".$selection."&";
} else {
$print_query = "?selection=".$selection."&TypeM=".$TypeM."&";
}
[/code]


Thanks for all ur help though

Adam
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...