Jump to content

help with veriable links


dingus

Recommended Posts

hello i am trying to set up a link that not only loads a new page but i also want to set a veriable on that page based on the link that iwas clicked on EG you have 4 links "dogs,cats,birds,fist" and you want all 4 links to point to the same page (EG. Example.php)

when you click the dogs link i want to set $animal to dogs on example.php

where as when you click on the cats it would set $animal to cats on example.php

and so on

if some one could please give me a code example or advice to help me with this because i spend over 8 hours today trying to google up the answer thank you
Link to comment
Share on other sites

Best way is a switch statement:
[code=php:0]switch(@$_GET['animal'])
{
    case 'cat':
    case 'dog':
        $animal = $_GET['animal'];
    break;
    default:
        $animal = '';
    break;
}
echo $animal . "<br />\n";
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.