Solved: PHP URL Help

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Eriksrocks

Thread Starter
Joined
Aug 7, 2005
Messages
2,183
Unless... does it have something to do with the mod_rewrite command in the .htaccess file?
 
Joined
Jan 18, 2005
Messages
220
Are you talking about creating this URL? That is just a variable being passed by GET. If that is what you are asking.
 

Eriksrocks

Thread Starter
Joined
Aug 7, 2005
Messages
2,183
slarti said:
Are you talking about creating this URL? That is just a variable being passed by GET. If that is what you are asking.
Yes, I want to "create" it. So then it is a variable? So, for example, if I had a file named test.php, and inside it was this:

<?php
$page = "";

if( $page == 1 )
{ $msg = "This is page 1"; }

else if( $page == 2 )
{ $msg = "This is page 2"; }

else
{ $msg = "This is not page 1 or page 2"; }

echo( "$msg" );
?>


And then I went to www.mysite.com/test.php?page=2 it would give me This is page 2?

I'm going to test it, but if the answer is yes, then this is just what I needed.
 

Eriksrocks

Thread Starter
Joined
Aug 7, 2005
Messages
2,183
Thank you so much. (y) That article is what I've been looking for for about, well... like 3 months!

Thanks again! :D
 
Joined
Jan 18, 2005
Messages
220
I am a little rusty on my PHP, haven't used it in a few months now that i don't design sites anymore. But I got pretty good by forum help. I am no means a programmer. I found the best way to search was to just put PHP in front of any queries in google.

Check out phpfreaks and devshed for articles and code snippets.;)
 
Joined
Apr 30, 2005
Messages
3,012
You can use switches if you want

PHP:
<?php

function index()
{
echo "Choose A Page";
echo('<a href=index.php?act=News>News</a>');
echo('<a href=index.php?act=Contact>Contact Us</a>');
}

$choice=$_GET['act'];

switch($choice)
{
case "News":
echo "News Goes Here";
break;

case "Contact":
echo "Contact Stuff Goes Here";
break;

default:
index();
}
?>
This method also seems to be more direct than others posted in here (y)
 

Eriksrocks

Thread Starter
Joined
Aug 7, 2005
Messages
2,183
Yes... Now on to build my next site. Of course it would make more sense to use the PHP include() function to sort of organize it all out... But thanks everybody! :)
 
Joined
Jul 8, 2002
Messages
14,681
No need to set a variable that's only going to be used once, you can just do switch($_GET['act'])
 

Eriksrocks

Thread Starter
Joined
Aug 7, 2005
Messages
2,183
brendandonhu said:
No need to set a variable that's only going to be used once, you can just do switch($_GET['act'])
Umm... Don't really understand that but that's OK. :rolleyes:
 
Joined
Apr 30, 2005
Messages
3,012
Eriksrocks said:
Umm... Don't really understand that but that's OK. :rolleyes:
He means in my code, I had:

$choice=$_GET['act'];

switch($choice)

He's saying I could have just put switch($_GET['act]) instead of having the variable $choice :D
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top