links help....php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

links help....php

Post by pleigh »

i have links in the left part of my page....now, what i want to do is when i click the links, the content of that link will be called to the right part of the default page....and i think it is much easier to do this than manually making another page for the corresponding links....is there a way i can do this??what style should i use in php...

many thanks...
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

Code: Select all

if (isset($_GET['page2display']))
{
   if ($_GET['page2display'] == "something")
   {
      // print the relevant page
   }
}
etc etc
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

here are some codes

Code: Select all

<table width=&quote;100%&quote; border=&quote;0&quote; cellspacing=&quote;0&quote; cellpadding=&quote;0&quote;>
  <!--spacer-->
  <tr valign=&quote;top&quote;>
    <td width=&quote;20%&quote;>&nbsp;</td>
    <td width=&quote;79%&quote;>&nbsp;</td>
	<td width=&quote;1%&quote;>&nbsp;</td>
  </tr>
  <!--end of spacer-->
  <tr valign=&quote;top&quote;>
  	<!--directory menu-->
    <td width=&quote;20%&quote;>
		<table width=&quote;100%&quote; border=&quote;0&quote; cellpadding=&quote;0&quote; cellspacing=&quote;0&quote;>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
			<tr align=&quote;center&quote;>				
				<td height=&quote;35&quote; background=&quote;images/submenu.jpg&quote; class=&quote;submenu&quote;><a href=&quote;&quote; class=&quote;under&quote;>Link</a></td>
			</tr>
		</table>
	</td>
	<!--end of directory menu-->
	<!--body of menu-->
    <td width=&quote;79%&quote;>
		<table width=&quote;100%&quote; border=&quote;0&quote; cellpadding=&quote;0&quote; cellspacing=&quote;0&quote;>
			<tr>
				<td width=&quote;1%&quote;></td>
				<td width=&quote;95%&quote;>
					<?
					include('somepage.php');
					?>
				</td>				
			</tr>
		</table>
	</td>
	<!--end body of menu-->
	<td width=&quote;1%&quote;>&nbsp;</td>
  </tr>
</table>
where can i insert the above code of malcolmboston?

many thanks malcolmboston..:)
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

seeing as your interested ill go a little more indepth, ok you have the links on your lef, sayb the page is called index.php just for simplicity, first define some common functions, this isnt the best way but once you have this sorted you can start streamlining

Code: Select all

function DefineContentToShow ()
{
   if($_GET&#1111;'page2display'] == &quote;link1&quote;)
   {
      print &quote;the content for this link here&quote;;
   }
   elseif ($_GET&#1111;'page2display'] == &quote;link2&quote;)
   {
      print &quote;the content for this link here&quote;;
   }
   else
   {
      // not defined, show generic intro
      print &quote;Generic Intro here&quote;;
   }
}
for eg, you have in your "HTML view"

Code: Select all

/---------------\ /-------------------------------\
|               | |                               |
|      link     |               content           
|               | |                               |
\---------------/ \-------------------------------/
in content put

Code: Select all

<?php DefineContentToShow (); ?>
also when defining links use the format

Code: Select all

&lt;a href=\&quote;index.php?page2display=link1\&quote;&gt;First Link&lt;/a&gt;
&lt;a href=\&quote;index.php?page2display=link2\&quote;&gt;Second Link&lt;/a&gt;
this is an incredibly simple solution, further work needs developing on this like sanitizing $_GET vars etc, but its a good starting point

Hope this helps you mate
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

of course it is very helpful....tnx a lot....:D
Post Reply