Page 1 of 1
please help....php wont work!
Posted: Fri May 05, 2006 3:11 am
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
Posted: Fri May 05, 2006 3:39 am
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.
is there another way?
Posted: Fri May 05, 2006 3:57 am
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
Re: is there another way?
Posted: Fri May 05, 2006 4:06 am
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
Posted: Fri May 05, 2006 4:14 am
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
Posted: Fri May 05, 2006 4:22 am
by JayBird
do it like this, variable variables is what you are lookign for
Posted: Fri May 05, 2006 4:25 am
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>
Posted: Fri May 05, 2006 4:25 am
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
