Page 1 of 1
Problem to linking a different file in the same page
Posted: Fri Mar 04, 2005 2:43 am
by ileyla
hi everybody
wanna ask u guys out there, now i have a problems to linking a different file within the same page. basically i have set the index page which display and comprise of three different file(right.php, left.php & main.php), using include function in php. the problem now is that,the left.php file contains a menu which will link to other page. What i want to know now is that, instead of linking the page to other new page, how can i link the menu and display the target file into where main.php located, without left.php and right.php location be changed
Hope u guys out there can helps me. Thanks al lot
feyd | bolding your entire post helps no one
Posted: Fri Mar 04, 2005 2:53 am
by pleigh
how about creating a new php document, including the include files you want to appear on the page
Posted: Fri Mar 04, 2005 7:52 am
by feyd
this is usually done through setting a url variable which will tell the main content script to change content..
Posted: Mon Mar 07, 2005 7:58 pm
by ileyla
what do you means by setting the url variable.Basically i have used the
<a href=?main="includes/page1.php" method..But it seems doesn't work at all.can u show me any guidelines or any method that i did not include in this code.

Posted: Mon Mar 07, 2005 8:18 pm
by feyd
example ONLY
Code: Select all
<?php
$includePath = '/your/includes/path/';
$page = (isset($_GET['p']) ? $_GET['p'] : '');
$knownPages = array('contact'=>'contact', 'products'=>'productsheet', 'default'=>'default');
if(array_key_exists($page, $knownPages))
{
$knownPage = $knownPages[$page];
}
else
{
$knownPage = $knownPages['default'];
}
include($includePath . $knownPage . '.php');
pages are called in this manor: main.php?p=contact
Posted: Tue Mar 08, 2005 6:58 am
by Phoenixheart
I think it might be easier using frames?
Posted: Tue Mar 08, 2005 7:34 am
by Chris Corbyn
Frames are dead.... avoid them where they are not necessarry at all costs. They cause all kinds of problems, especially with search engines.
I use a switch() condition to change the content based upon the url variable. Kinda like feyd said.
Posted: Tue Mar 08, 2005 8:20 am
by timvw
why are frames dead?
what problems do they cause with search engines?
Posted: Tue Mar 08, 2005 9:13 am
by Chris Corbyn
Uh oh... I can see I have started something here......
Well ok they aren't dead but developers previously used them for structuring pages, to get menus in one frame, a header in another etc....
I may have exaggerated just a bit in my last post
Search engines see these individual frames as separate pages and when viewed, these pages do not appear the way they should do. There are ways around it using JavaScript trickery to redirect if the page isn't being viewed in the frameset - but then that's JS dependant.
In general I find that if it's just for the sake of having a nice layout in easy to manage individual files, I'd prefer to use includes in PHP along with the relevant switch conditions to change what is called in the includes depending upon values in $_GET.
Of course, frames do have their uses still. It's just that it is not always ideal to use them, and I try to avoid them as much as possible.
This is just my personal opinion though

Posted: Tue Mar 08, 2005 11:41 pm
by ileyla
oo ok..thanks for all the guidelines thanks feyd!!..btw i'm still working on that problems..
Lots of thanks everybody
