How do I do this ?id

I am trying to create a site that will be easy to maintain. I have come across and like the way the urls work instead of having

it shows something like this can someone please tell me how to do this thanks

in your example (since you didn’t specify any actual page) id becomes a variable in your default page (probably index.php). Generally accessible by using the GET method.

You can access it’s value by using the superglobal of $_GET[‘id’] which would contain the value of 63.

Everything AFTER the ? is part of the query string. In the form of variableName=Value To pass more than ONE variable you separate them with the Ampersand (&) sign Var1=Val1&Var2=Val2&Var3=Val3

Also accessed by your script by using the superglobal $_GET[‘VarName’]

A problem will arise (error messages) if you try to get a variable and none was passed. For example if, in your script you look for $_GET[‘id’] and the page was navigated to without using the ?id=63 you will get an undefined index.

You need to just check to see if it’s set first (isset() and then make the logic based upon the result.

I was trying to do it like does I really liked the look

Trying to do WHAT? The ?ID thing?

That is just part of the GET Method of html pages and is not unique to that sige.

Did you get your question resolved or do you need more info?

Sorry I fell stupid
I am pretty new to PHP and was wondering why this code will only show the die part

<?php $Page_ID = $_GET[ID]; if(Page_ID == "1"){ echo "Page 1"; } elseif($Page_ID == "2"){ echo "Page 2"; }else { Die('Sorry Page ID not valid'); } ?>

the url of the site is http://localhost/?id=1

Have a look of the RED stuff. That might help.

<?php $Page_ID = $_GET[[b]'[/b]ID[b]'[/b]]; if([b]$[/b]Page_ID == "1"){ echo "Page 1"; } elseif($Page_ID == "2"){ echo "Page 2"; }else { Die('Sorry Page ID not valid'); } ?>

Thanks I appreciate your help

Sponsor our Newsletter | Privacy Policy | Terms of Service