PHP in url?
Moderator: General Moderators
PHP in url?
Hi,
I'm only 14 and im trying to earn PHP now one thing thats bugging me is how you make a files name like this:
http://www.beyondunreal.com/daedalus/ar ... php?show=5
Things that have like .php?show=5 or .php?id=15 ect... how do i do that?
I'm only 14 and im trying to earn PHP now one thing thats bugging me is how you make a files name like this:
http://www.beyondunreal.com/daedalus/ar ... php?show=5
Things that have like .php?show=5 or .php?id=15 ect... how do i do that?
everything after the ? is called the GET string.
PHP takes this and sets variables according to what it finds.
For example:
http://www.beyondunreal.com/daedalus/ar ... php?show=5
If you went to that page and it contained:
<?php
echo "Show equals ".$show;
?>
then you would see on the page:
"Show equals 5"
pretty simple, huh?
PHP takes this and sets variables according to what it finds.
For example:
http://www.beyondunreal.com/daedalus/ar ... php?show=5
If you went to that page and it contained:
<?php
echo "Show equals ".$show;
?>
then you would see on the page:
"Show equals 5"
pretty simple, huh?
Ok sorry i cant really like explain it good but here goes:
On my site i want the main page of my site to be index.php then in the menu i will put a link <a href="http://www.mysite.com/index.php?=map1">Maps</a> but what i want to know is how do i created a page with a file name ending index.php?=map1
On my site i want the main page of my site to be index.php then in the menu i will put a link <a href="http://www.mysite.com/index.php?=map1">Maps</a> but what i want to know is how do i created a page with a file name ending index.php?=map1
and that's what i was telling you in the first place...you dont make another file with that name.
the part after the ? is a GET string. PHP sees that and turns it into variables for you.
so if the URL is "index.php?id=5" then, when you load that URL, the index.php page is the same, except it now has a variable of $id set to a value of "5"
It's all the same page.
the part after the ? is a GET string. PHP sees that and turns it into variables for you.
so if the URL is "index.php?id=5" then, when you load that URL, the index.php page is the same, except it now has a variable of $id set to a value of "5"
It's all the same page.
But a while ago on another forum i posted on they said something about these things:
Code: Select all
<?
include('_header.php');
if($page==1)
{
?>
blablablabla
<a href=view.php?page=2>Next Page</a>
<?
}
if($page==2)
{
etc.....
}- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
the part after the ? is a variable .. if you have:
http://somewhere/index.php?theme=2
then PHP says .. "A variable name $theme was passed to the URL and it contains the value '2'"
inside your script you would say ...
So whatever number is passed .. index.php?theme=1 or index.php?theme=2 or whatever, then the variable and the value of that variable are set and you can deal with them in your code
--
protokol
http://somewhere/index.php?theme=2
then PHP says .. "A variable name $theme was passed to the URL and it contains the value '2'"
inside your script you would say ...
Code: Select all
<?php
switch ($theme) {
case 0:
echo "You are using theme 0";
break;
case 1:
echo "You are using theme 1";
break;
case 2:
echo "You are using theme 2";
break;
default:
echo "You are using the default theme";
break;
}
?>--
protokol
- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
if you are inside double quotes, and wish to print a double quote explicitly, then you use \"
Code: Select all
echo "<a href="index.php?theme=1">Theme #1</a>";
Last edited by protokol on Fri Jun 21, 2002 7:26 pm, edited 1 time in total.