PHP ?id= SYSTEM

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sb
Forum Newbie
Posts: 3
Joined: Sat Jun 14, 2003 1:30 pm

PHP ?id= SYSTEM

Post by sb »

Hi!

I need to know how we do ?id= thing in PHP. I know how to do it in ASP. In ASP, we do it like:

<%
If Request.QueryString("id")="" Then
%>
DEFAULT TEXT

<%
End If
If Request.QueryString("id")="car" Then
%>
CAR PAGE

<%
End If
If Request.QueryString("id")="bus" Then
%>
BUS PAGE

<%
End If
%>

When we type PAGE.asp?id=car, the car page appears. I just need to know how we do it in PHP. Please tell me.


Thanks.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

See :

viewtopic.php?t=511

Regards,
sb
Forum Newbie
Posts: 3
Joined: Sat Jun 14, 2003 1:30 pm

But...

Post by sb »

But I don't want it in a Form type. I want it in normal type, like I told you in ASP. Please tell me in detail. Thanks.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Direct conversion (assuming asp styles tags are off):

Code: Select all

<? if($_GET['id'] == "") { ?> 

DEFAULT TEXT 

<? } if($_GET['id'] == "car") { ?> 

CAR PAGE 

<? } if($_GET['id'] == "bus") { ?>

BUS PAGE 

<? } ?>
But what I think you need is:

Code: Select all

<?php

	if($_GET['id'] == "")
	{  
		echo "DEFAULT TEXT";
	} elseif($_GET['id'] == "car") {
		echo "CAR PAGE";
	} elseif($_GET['id'] == "bus") {
		echo "BUS PAGE";
	}

?>
Please see:

http://www.php.net/manual/en/control-structures.php
http://www.php.net/manual/en/control-st ... s.else.php
http://www.php.net/manual/en/language.v ... efined.php

Regards,
Post Reply