This is a discussion on alternative $link if no id exists in URL within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I was wondering how I can do the following. Example: When a surfer goes to index.php there is a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I was wondering how I can do the following.
Example: When a surfer goes to index.php there is a list of links including example.php. I only want the link to appear as example.php if a id variable is given in the url. Example. www.mydomain.com/index.php?id=564, if not "ID" is given, example www.mydomain.com/index.php or www.mydomain.com/index.php?othervariable=5, I would like the example.php link to go to example2.php instead of example.php. Something like: $link = example, if no ID exists, $link=example2. In the source the link will appear as www.mydomain.com/$link.php. I am new to php and don't know how I would put this in proper code. Hope someone can help. |
|
|||
|
"1" <tre-cool@rogers.com> kirjoitti
viestissä:XcKdnZE2274uYQXeRVn-qg@rogers.com... > Something like: $link = example, if no ID exists, $link=example2. $link = isset($_GET['ID']) ? 'example' : 'example2'; That menas that if the parameter ID was supplied in the page call, 'example' is assignet into $link, in any other case 'example2' will be assigned to $link. Was this what you wanted? -- SETI @ Home - Donate your cpu's idle time to science. Further reading at <http://setiweb.ssl.berkeley.edu/> Kimmo Laine <antaatulla.sikanautaa@gmail.com.NOSPAM.invalid> |
|
|||
|
That worked, thanks so much!
"1" <tre-cool@rogers.com> wrote in message news:XcKdnZE2274uYQXeRVn-qg@rogers.com... > I was wondering how I can do the following. > > > > Example: When a surfer goes to index.php there is a list of links including > example.php. I only want the link to appear as example.php if a id variable > is given in the url. Example. www.mydomain.com/index.php?id=564, if not "ID" > is given, example www.mydomain.com/index.php or > www.mydomain.com/index.php?othervariable=5, I would like the example.php > link to go to example2.php instead of example.php. > > > > Something like: $link = example, if no ID exists, $link=example2. In the > source the link will appear as www.mydomain.com/$link.php. > > > > I am new to php and don't know how I would put this in proper code. Hope > someone can help. > > > |