alternative $link if no id exists in URL

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-09-2005
1
 
Posts: n/a
Default alternative $link if no id exists in URL

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.



Reply With Quote
  #2 (permalink)  
Old 12-09-2005
Kimmo Laine
 
Posts: n/a
Default Re: alternative $link if no id exists in URL

"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>


Reply With Quote
  #3 (permalink)  
Old 12-09-2005
1
 
Posts: n/a
Default Re: alternative $link if no id exists in URL

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.
>
>
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:28 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0