konetch Posted July 22, 2009 Share Posted July 22, 2009 I have two files: newlink.php and index.php IN newlink.php I have a class where I want it so that when one function is excecuted the other one will display. TO make myself clearer I want it so that when I click a link like localhost/index.php?post=1 it will come up with HELLO World Understand. Here are the two files newlink.php <?php class newlink { public function displayLink () { ?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?post=1">Read my first page!!!</a> <?php } public function displayPage () { ?> <h2>Hello World</h2> <p>This is a test post</p> <?php } } ?> index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Home</title> </head> <body> <?php require_once("newlink.php"); $obj = new newlink(); echo $obj->displayLink(); ?> </body> </html> I've got most of it down I think I just need something that will diplay the post when I click the link. Can you tell me how to do this. Thanks If I'm not clear enough jsut ask. I'll reply quickly Quote Link to comment https://forums.phpfreaks.com/topic/166913-solved-display-an-page-after-clicking-a-link/ Share on other sites More sharing options...
Q Posted July 22, 2009 Share Posted July 22, 2009 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Home</title> </head> <body> <?php require_once("newlink.php"); $obj = new newlink(); if (isset($_GET["page"]) && $_GET["page"] == 1) { echo $obj->displayPage(); } else { echo $obj->displayLink(); } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/166913-solved-display-an-page-after-clicking-a-link/#findComment-880039 Share on other sites More sharing options...
konetch Posted July 22, 2009 Author Share Posted July 22, 2009 Thanks for the reply, but this didn't work, for some reason. I'm still new, but I can see the logic behind for code. Perhaps it's an issue with this line of code if (isset($_GET["page"]) && $_GET["page"] == 1) Quote Link to comment https://forums.phpfreaks.com/topic/166913-solved-display-an-page-after-clicking-a-link/#findComment-880042 Share on other sites More sharing options...
konetch Posted July 22, 2009 Author Share Posted July 22, 2009 okay never ming I got it working changed it to if (isset($_GET["post"]) && $_GET["post"] == 1) { Quote Link to comment https://forums.phpfreaks.com/topic/166913-solved-display-an-page-after-clicking-a-link/#findComment-880044 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.