Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2011, 01:55 AM   PM User | #1
jhbug
New to the CF scene

 
Join Date: Nov 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
jhbug is an unknown quantity at this point
Question PHP frame/includes problem

Hi! I'm new to PHP, so forgive me if I am missing an obvious answer. I can't get a small portion of my include or switch statement to work correctly.
I am trying to develop my own site using PHP instead of frames with this layout:


|_________________________|
|_______ Header __________|
|_________________________|
[__ Nav1___ Nav2 ___ Nav3 __]
|_________________________ |
|_________________________ |
|_________________________ |
|_______ Content __________|
|_________________________ |
|_________________________ |

But within the content, I am trying to make a seperate navigation list like this:


(Content)
| [subnav item1] ___ subContent _____|
| [subnav item2] ___________________|
| [subnav item3] ___________________|

where the subContent changes depending on which subnav item is clicked.

To do this, I've been using something like this:
Code:
<!-- Sample -->
<div id="header">
       <?php include('header.php')?>
</div>

<a id="nav" href="index.php?page=nav1">Nav1</a>
<a id="nav" href="index.php?page=nav2">Nav2</>
//etc for nav3

<?php
       $page = $_GET['page'];

       switch ($page){
                 case "nav1":
                        include('Nav1.php');
                       break;
                //etc for nav2, nav3
                 default:
                        include('home.php');
         } ?>

And then within Nav1 I will have:
           <div id="subnav">
                  <?php include('subnav.php')?>
            </div>

            <div id="subcontent">
                   <?php 
                        $subc = $_GET['page']
                       switch($subc){
                                  case "sn1":
                                      include('subnav1.php'); break;
                                  default: include(Nav1_home.php) }?>
etc..

So when I visit my page, everything works except the includes statement for the content. The address bar would say "http://website.com/index.php?page=subnav1" but it would show the home page instead of the content which was written in the file subnav1.php. But however, when I visit say Nav1, the default includes "Nav1_home.php" will show up in the subcontent area

Is this because I can't do multiple switch/include statements within each other? How can I work around that? If not, what am I doing wrong?

I've been trying to search multiple forums for a problem close to this but I have not been able to come across one :[
jhbug is offline   Reply With Quote
Old 11-12-2011, 08:41 AM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
Saying "using PHP instead of frames " is like saying you want an apple orchard without planting orange trees. We say Of Course

So you want a horizontal menu and in the main area under that you want a vertical menu

check these out
http://www.alvit.de/css-showcase/css...s-showcase.php
sunfighter is offline   Reply With Quote
Users who have thanked sunfighter for this post:
jhbug (11-12-2011)
Old 11-12-2011, 04:37 PM   PM User | #3
jhbug
New to the CF scene

 
Join Date: Nov 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
jhbug is an unknown quantity at this point
Haha... so i'm not totally understanding the apple orchard analogy. Thanks for the website though! it is very useful to see with the different designs. i will be sure to reference it in the future when i am thinking about more designs. however, i don't see it helping this problem much.

i wanted to be able to load the subcontent without having to reload the page everytime a new navigation link has been clicked. however, i realize now that wanting that would be crossing into ajax and jquery territory so i have some more learning to do now...
jhbug is offline   Reply With Quote
Reply

Bookmarks

Tags
$_get, frame, include, php, switch

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:53 PM.


Advertisement
Log in to turn off these ads.