davidcriniti Posted February 21, 2013 Share Posted February 21, 2013 I have been trying to find a way to use php to display content in the main area of my page, based on a link clicked on the side of my page. The closest thing to what I'm after is done with jquery: http://jsfiddle.net/5NEu3/3/ Was wondering how it would be done with php. Ie: What would I do with the table below, which has 3 links in the left column, and 3 sentences is the right. Each only to be displayed when their link is clicked, and hidden again if any of the others are clicked. Any advice would be greatly appreciated. Cheers, Dave <table width="100%" cellpadding="3"> <tr> <td> <a href="???">Link 1 </a><br /> <a href="???">Link 2 </a><br /> <a href="???">Link 3 </a><br /> </td> <td> Show if and when Link 1 is Clicked. Hide if anything else is clicked. Show if and when Link 1 is Clicked. Hide if anything else is clicked. Show if and when Link 1 is Clicked. Hide if anything else is clicked. </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/274766-display-html-based-on-link-clicked/ Share on other sites More sharing options...
denno020 Posted February 21, 2013 Share Posted February 21, 2013 You could give each a link to the current page with a get variable set, then using php to process the get variable, display whichever line you want. <a href="this.php?link=1">Link 1</a> <?php if(isset($_GET['link']) && $_GET['link'] == '1'){ echo "Show if and when Link 1 is Clicked....."; } ?> You could expand on that for the rest. Obviously this will require a page refresh. If you want to do with without a page refresh, then you'll need to look at using AJAX, which means you'll have to use javascript as well.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/274766-display-html-based-on-link-clicked/#findComment-1413881 Share on other sites More sharing options...
davidcriniti Posted February 21, 2013 Author Share Posted February 21, 2013 Thanks Denno. That worked perfectly! Quote Link to comment https://forums.phpfreaks.com/topic/274766-display-html-based-on-link-clicked/#findComment-1414031 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.