954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HELP.....URL, PHP, Rollover Links

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

aformoftruth
Newbie Poster
2 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

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

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

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.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You