Page 1 of 1

links help....php

Posted: Mon Jun 06, 2005 5:25 am
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...

Posted: Mon Jun 06, 2005 5:30 am
by malcolmboston

Code: Select all

if (isset($_GET['page2display']))
{
   if ($_GET['page2display'] == "something")
   {
      // print the relevant page
   }
}
etc etc

Posted: Mon Jun 06, 2005 5:44 am
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..:)

Posted: Mon Jun 06, 2005 5:54 am
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

Posted: Mon Jun 06, 2005 5:58 am
by pleigh
of course it is very helpful....tnx a lot....:D