I have a list of links that all link to the same page. I want to make it so that depending on which one of the links you click, the page will render differently. So for example, you're on list.php. You click on the "SC" link. You are taken to page.php where you see "SC is located in the South." If you click on "NY," you are also taken to page.php but it says "NY is located in the North." I'm not sure how to have a variable associated with a link, or if it's even possible to do it like that. The following is what I had in mind, but the "list" page is the one I'm not sure about.

<a href="page.php" $id="SC">SC</a>
<a href="page.php" $id="NY">NY</a>

$south = array("SC");
$north= array("NY");
if (in_array(id, $south, true)) {
render("page_view.php", ["state" => $id, "region" => "South"]);
if (in_array(id, $north, true)) {
render("page_view.php", ["state" => $id, "region" => "North"]);

<p><?=$state?> is located in the <?=$region?>.

1 Answer 1


How about:


<a href="page.php?geo=SC">SC</a> 
<a href="page.php?geo=NY">NY</a>

PAGE does logic based on $_GET["geo"]

  • Worked great! Thank you!
    – K. Rich
    Commented Apr 23, 2017 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .