please help....php wont work!

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
bestm8ts
Forum Newbie
Posts: 4
Joined: Fri May 05, 2006 2:57 am

please help....php wont work!

Post by bestm8ts »

hi, i need a bit of help!

im setting up a new website and was hoping to make the navigation dynamic...
i have set all the links on the page to something like ?L=home which would tell the page to bring up the home content (hopefully)
where i want the home content to be shown i have put
$_GET["L"]

now obviously this doesnt work because i have not put the dollar sign in there so it wont know its a tag.

i was wondering, if i wanted to turn the dynamic navigation into something that pulls content to the page where would i put the $

or is this the wrong thing to do?

please advise.

Thanks
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

Ok, I think you’re a bit confused regarding the basic syntax of php.

The $_GET that you are referring to, is to GET the variable value in the URL.

e.g.

http://localhost/my_site/navigation.php?page=home

On the navigation page, if you echoed $_GET['page'], the value would be home.

So if you wanted to load pages according to that variable, you could require them using:

Code: Select all

require($_GET['page'].".php"); // this will load the home.php page, referring to the example
Have a look at the PHP manual; all of the concepts are there.
bestm8ts
Forum Newbie
Posts: 4
Joined: Fri May 05, 2006 2:57 am

is there another way?

Post by bestm8ts »

do you know if there is any way of using the $_GET["whatever"] synax to be part of a tag?

all i really need to do is get the dollor sign infront of the $_GET and it should work. if you know of a way i would be very greatfull....

Thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: is there another way?

Post by JayBird »

bestm8ts wrote:all i really need to do is get the dollor sign infront of the $_GET and it should work. if you know of a way i would be very greatfull....
I really dont know what you mean by that!

Can you explain yourself better please
bestm8ts
Forum Newbie
Posts: 4
Joined: Fri May 05, 2006 2:57 am

Post by bestm8ts »

on my website i have set all my links to index.php?L=home (the page replaces home)

i have a tag called $home that has the home content attatched and the same for other keywords like contact....

what i need to do is get from the ?L=home in the name to <? print $home ?> so i can pull the content to the page.

please help if you can but if its impossible please let me know so i can give up trying.

my goal is to create a website that is totally dynamic and all located in one file.

Thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

do it like this, variable variables is what you are lookign for

Code: Select all

echo ${$_GET["L"]};
Last edited by JayBird on Fri May 05, 2006 4:25 am, edited 1 time in total.
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

Honestly, your concept of php is incorrect.

My basic example should be adequate.

Regarding the tags, php is embedded into html. So you could simply echo it inside the html.

example not related to your issue:

Code: Select all

<a href="<?php echo $_GET['whatever'].".php"; ?>">Open the whatever page</a>
bestm8ts
Forum Newbie
Posts: 4
Joined: Fri May 05, 2006 2:57 am

Post by bestm8ts »

OMG PIMPTASTIC I COULD KISS YOU!!

no joke, i have been offline for 7 hours trying different things and its such a relief to finally get it.

if i had money i would send it u, thats how greatfull i am (unfortunatly im a poor student lol)

thanks :D
Post Reply