Page 1 of 1

PHP ?id= SYSTEM

Posted: Sat Jun 14, 2003 1:30 pm
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.

Posted: Sat Jun 14, 2003 2:16 pm
by cactus
See :

viewtopic.php?t=511

Regards,

But...

Posted: Sat Jun 14, 2003 2:30 pm
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.

Posted: Sat Jun 14, 2003 3:16 pm
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,