adchico Posted October 8, 2007 Share Posted October 8, 2007 I have the index.php other pages: about.php index.php contact.php In this page I have a table where I want the other pages to show when I click its link. I know how to use <?php include("about.php") ?> but how will i use this to trigger different pages to show in a table cell if I click the about link or the contact link? Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/ Share on other sites More sharing options...
TomKrush Posted October 8, 2007 Share Posted October 8, 2007 Can you better phrase this question. I understand that you have a table. And if you click on a link you want it to direct you to a page. Where is your issue in include()? Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364328 Share on other sites More sharing options...
adchico Posted October 8, 2007 Author Share Posted October 8, 2007 Im sorry about that ... Im just a noob in php ... Im going to make this as simple as I can =) I have a page index.php with tables in it I have several links Home About Contact Us When a Link is selected, how can I make the Page to be opened, open up in one of the tables? here is what im trying to do if Home link is selected <td><?php include("index.php"); ?></td> if About link is selected <td><?php include("about.php"); ?></td> <--- in the same table cell if Contact Us link is selected <td><?php include("contact.php"); ?></td> <--- in the same table cell Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364334 Share on other sites More sharing options...
TomKrush Posted October 8, 2007 Share Posted October 8, 2007 First off, your not a noob. We all started off somewhere. All you need to make this work is a some sort of variable that you can pass through to the script. So no matter what link your user clicks on he or she will always be sending a message to the php script. In this example I used a get var in the url query. I have it so each link has a section variable. The code below works in both php 4 and php 5 environments. The only thing that would need to be change is the HTTP_GET_VAR. PHP 5 doesn't use HTTP_GET_VARS anymore so it would need to be replaced with $_GET. <table> <tr> <td><a href="?section=home">Home</a></td> <td><a href="?section=about">About</a></td> <td><a href="?section=contact">Contact</a></td> </tr> <tr> <?php $section = $HTTP_GET_VARS["section"]; //$_GET if your using php5 if($section == "home") { include("home.php"); } if($section == "about") { include("about.php"); } if($section == "contact") { include("contact"); } ?> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364360 Share on other sites More sharing options...
trq Posted October 8, 2007 Share Posted October 8, 2007 PHP 5 doesn't use HTTP_GET_VARS anymore Niether does php4. $_GET[] is the prefered method. Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364383 Share on other sites More sharing options...
adchico Posted October 8, 2007 Author Share Posted October 8, 2007 @TomKrush first of all I want to thank you for your help I get the idea http://localhost/mywebs/www/index.php?section==home or http://localhost/mywebs/www/index.php?section==about is showing in the url but the problem is the include file is not showing up the about.php is not showing up in the table Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364402 Share on other sites More sharing options...
trq Posted October 8, 2007 Share Posted October 8, 2007 Post your code. Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364404 Share on other sites More sharing options...
adchico Posted October 8, 2007 Author Share Posted October 8, 2007 Im sorry here is the code I followed the instruction on the link: <td width="93"><div align="center" class="style40"> <a href="?section==home">Home</a></div></td> <td width="96"><div align="center" class="style49 style44 style45"> <a href="?section==about">About Us</a></div></td> and the code of include in the table cell: <?php $section = $_GET["section"]; //$_GET if your using php5 if($section == "home") { include("index.php"); } if($section == "about") { include("about.php"); } ?> </td> Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364407 Share on other sites More sharing options...
trq Posted October 8, 2007 Share Posted October 8, 2007 Your links should be... <a href="?section=home">Home</a> Only one = Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364410 Share on other sites More sharing options...
adchico Posted October 8, 2007 Author Share Posted October 8, 2007 WOW amazing Im new here in phpFreaks.com but Im really surprised that you guys did solved my PHP problem immediately!!! This is a great Forum! Thanks I really am happy with the result! Quote Link to comment https://forums.phpfreaks.com/topic/72250-solved-how-do-i-use-include-in-multiple-links/#findComment-364419 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.