I have a URL PHP LINKs problem...

I'm a newbie and am currently teaching myself php and html...currently using dreamweaver and have been able to be pretty lazy with regards to learing code but now am using php...and got to type it in myslef....its good for me.

But i have a menu system with rollovers(LINKS) and want to assign a onclick variable to them, then have the main content change and navigate to a php page.....

Have tried href=<?PHP $page= "home.php";?> and this doesn't work should i be using onclick? How? Do i need to reset $pager variable each time....how?

And in my main content i have written <?PHP include("$page");?> and when it does it puts a lot of space in the content page.

This is a basic page i'm writing for this page you can view the source there isn't any php in it yet.

www.thesilvergem.vndv.com

Thanks everyone.

aformoftruth

Recommended Answers

All 2 Replies

If you are looking to change the content on the page dynamically (without reloading) then you should look into Javascript/AJAX for this.

Believe it or not this is just barley possible to do with php (and a little html). What you need to do is setup an iframe and make the link submit to the iframe with a url variable. Then when the iframe reloads, it gets the url variable and assigns it to a session variable making it available to the first page.

Below is the code for the page with the link (note that the very first thing the page starts with is the php code opening bracket:

<?
session_start();
$page=$_SESSION['page'];
?>
<iframe src='iframe.php' name='iframe' width='1' height='1' frameborder=0 scrolling='no'></iframe>
<a href='iframe.php?page=home.php' target='phpiframe'>Test Link</a>

Note that in the link, after the phrase "page=", it is then followed by what you want the $page variable to be. Now for the php iframe. So in the same folder, create a page named iframe.php and place in it the following code:

<?
session_start();
$_SESSION['page']=$_GET['page'];
?>

Now when you click the link it will return the "page=x" (in the link) as "$page=x". Just let me know if you need more info.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.