Forum Moderators: coopster

Message Too Old, No Replies

Retrieving dynamic content with query strings

         

Stephen88

1:36 pm on Sep 2, 2003 (gmt 0)

10+ Year Member



Hi everyone, im quite new to PHP and i used to use ASP and in ASP i could use this script to retrieve multiple dynamic content from one particular page with different query strings:


<html>
<head>
</head>
<body>
<p><a href="default.asp?">default</a></p>
<p><a href="default.asp?page=1">page 1</a></p>
<p><a href="default.asp?page=2">page 2</a></p>
<p><a href="default.asp?page=3">page 3</a></p>
<%
If Len(Request.QueryString("page"))=0 Then
%>
You are on the default page
<%
Elseif Request.QueryString("page")="1" Then
%>
You are on page 1
<%
Elseif Request.QueryString("page")="2" Then
%>
You are on page 2
<%
Elseif Request.QueryString("page")="3" Then
%>
You are on page 3
<%
End If
%>
<body>
</html>

I was wondering if you could do this with PHP?
or convert it to PHP?
I know that in PHP you could redirect to another page with query strings but i would like to have as little pages as possible and keep the information on one page istead of multiple pages.

I appreciate your help, Thank you

Nick_W

1:39 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




if($_GET['page']==1) {
// do stuff
}

Oh, and welcome to WebmasterWorld!

Nick

Stephen88

11:16 am on Sep 3, 2003 (gmt 0)

10+ Year Member



Ohh i get it so its something like this, which i have tried and worked, thanks for your help Nick_W:

<html>
<head>
</head>
<body>
<p><a href="default.php?page=1">page 1</a></p>
<p><a href="default.php?page=2">page 2</a></p>
<p><a href="default.php?page=3">page 3</a></p>
<?php
$page=$_GET['page'];
switch($page) {
case "1" :?>
you are on page 1
<?php break; case "2" :?>
you are on page 2
<?php break; case "3" :?>
you are on page 3
<?php break; default:?>
you are on the default page
<?php }?>
<body>
</html>

ASP and PHP are so similar~!