Jump to content

display html based on link clicked


davidcriniti

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/274766-display-html-based-on-link-clicked/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.