hey_im_chris Posted July 4, 2006 Share Posted July 4, 2006 Hey everyone,Just a quick question I'd like to resolve tonight...I have an index page that holds the php include script, and pages are called into that. The first page it calls has several links on it, which need to go to other pages in other directories, BUT, here's where the problem is: I don't know how to link to a page in another directory, since simply trying [i]index.php?x=dir1/page[/i] tries loading index.php?x=page and that's it. Is there a way to write a filepath that fixes this problem?If it helps, a basic look at my directory is:Main Directory - dir1 - page.php - index.phpI hope I've explained my problem sufficiently enough that somebody can explain to me what I need to do! Thanks in advance! :)Chris Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/ Share on other sites More sharing options...
mrwhale Posted July 5, 2006 Share Posted July 5, 2006 I'm not sure if this will help, but have you tried urlencode() Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53115 Share on other sites More sharing options...
hey_im_chris Posted July 5, 2006 Author Share Posted July 5, 2006 I've never tried that before. How does it work? :) Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53250 Share on other sites More sharing options...
wildteen88 Posted July 5, 2006 Share Posted July 5, 2006 Urlencode will not help. But what you might want to do is to create an array of all the pages that are in different directories. The use an if statement to check the page being included if its in the array of pages in different directories. If it is use the path in the array for that page.Sounds complicated? Its not but very straight forward if you understand arrays. Heres a quick demo of what I mean:[code=php:0]<?php// check that 'page' is set in the urlif(isset($_GET['page'])){ // now we setup our array of pages in different folders // the following is the format of our array: // array([pagename] => array([filename], [path to file])); // Our pages array $pages = array("about" => array("index.php", "./about/"), "contact" => array("contact.php", "./pages/"), "products" => array("list-products.php", "./shop/") ); // Now we check wether the page needed to be included is in our pages array if(array_key_exists($_GET['page'], $pages)) { // now we include our page: echo "include '" . $pages[$_GET['page']][1] . $pages[$_GET['page']][0] . "';"; } // if it wasn't we presum its its in the same folder as this script else { echo "include './" . $_GET['page'] . ".php';"; } echo "<br />\n<br />\n";}?>Include: <a href="?page=about">About page</a> | <a href="?page=contact">Contact page</a> |<a href="?page=products">Products</a> | <a href="?page=home">Home</a>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53273 Share on other sites More sharing options...
hey_im_chris Posted July 5, 2006 Author Share Posted July 5, 2006 Thanks for that! It seems quite straight-forward, actually. I'm a total php noob because I only learn what I need to when I need to use it. Tonight I'm learning about arrays! ;DEDIT:Okay, first of all, I'm having a bit of bother about how to load a page called 'gallery.php' as the default page that gets loaded at the start. Basically, what I want to achieve is:1. index.php loads a text page with links to other pages called 'gallery.php'.2. gallery.php has many links to pages in many other directories, which will load into index.php.I could easily achieve this (as I have done already) with a simple iframe, but I don't want the inherent scrollbar and how I got past that in the past was to use a script that set the iframe dimensions to the exact dimension of the various pages it will load. BUT, that only worked in IE. This time, it is very important to me that the site works in Mozilla Firefox and Opera.Thanks for your help so far, but if anyone can offer any advice about how to go about achieving my plan, I would be very damn grateful! :D Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53583 Share on other sites More sharing options...
hey_im_chris Posted July 6, 2006 Author Share Posted July 6, 2006 *...16 hour bump* ::) Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53802 Share on other sites More sharing options...
DaveLinger Posted July 6, 2006 Share Posted July 6, 2006 so you want the links to open in the same page without reloading the entire page, or does that matter? Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53823 Share on other sites More sharing options...
hey_im_chris Posted July 6, 2006 Author Share Posted July 6, 2006 I'd prefer to have it so that plain text pages will load into the main page (index.php), which holds the quite image-intensive layout design. Is that what you mean? :-\;) Quote Link to comment https://forums.phpfreaks.com/topic/13683-includes-help-please/#findComment-53853 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.