dynamic url to change one link on page

beachman1975

New member
Jan 21, 2011
5
0
0
What I want to do is the following:
I have a single webpage for example:
MYWEBPAGEdotCOM/INDEX.HTML
that will always look the same, except for one link on the page.
the link would be on the page for example:
LINK TO AFFILIATE:
affiliatedotCOM/my-affiliate_code_her_DYNAMIC_REFERER
the only thing would change is the "DYNAMIC_REFERER" with every dynamic url on this page:
MYWEBPAGEdotCOM/INDEX.PHP?id=test1 Url would change the link to: affiliatedotCOM/my-affiliate_code_here_test1
MYWEBPAGEdotCOM/INDEX.PHP?id=test2 Url would change the link to: affiliatedotCOM/my-affiliate_code_here_test2
MYWEBPAGEdotCOM/INDEX.PHP?id=test3 Url would change the link to: affiliatedotCOM/my-affiliate_code_here_test3
MYWEBPAGEdotCOM/INDEX.PHP?id=test4 Url would change the link to: affiliatedotCOM/my-affiliate_code_here_test4

Can someone tell me how I could go about doing this?
I just dont want to have to make 100's of pages, as this would prevent me from having to do so.
 


If I understand you, just write a function that takes a given ID, passes it through a big switch statement, and spits out the proper link. Or load all the URLs into a database and write a function that queries them based on a passed ID. Or put them in a text file with each line being id,link. Load text file and query that. Or use a chain of if/else.

Am I missing something here?
 
Several ways to do it; here's one:


Code:
<?php

$url = "http://{$_SERVER['HTTP_HOST']}/my-affiliate_code_here_{$_GET['id']}";

?>

And in the HTML:
Code:
<a href="<?php echo $url;?>">Click Here Bro</a>
 
Do what he did, and if you want to specify a default for when there's no "?id=" specified, replace $_GET['id'] with $id, then put this line above it:
Code:
if (isset($_GET['id'])) {
$id = $_GET['id']
} else {
$id = "default"
}
Change default to whatever you want.
 
Do what he did, and if you want to specify a default for when there's no "?id=" specified, replace $_GET['id'] with $id, then put this line above it:
Code:
if (isset($_GET['id'])) {
$id = $_GET['id']
} else {
$id = "default"
}
Change default to whatever you want.
Is this alteration correct?
I am getting parse errors on the change