Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New to CSS, have a general question

    Okay, been trying things out in CSS to form a layout. I have my main content div, all the things that will be displayed in this div is php. My question is, when users click navigation links in my page, can a div load html or php pages in to the main div, or do I have to break the page into a header.inc/footer.inc and on the other pages tpe my code and include those files accordingly? Hope this makes sense...trying to basically see if you can load pages into the div or do you basically have to use a template system.

  • #2
    New Coder
    Join Date
    Mar 2004
    Location
    CAMBODIA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could do that by put this code in your main <div> and modify if you need.

    <div id="main">
    <?php

    if (!isset($_GET['page'])) $page="welcome" ; else $page=$_GET['page'];
    switch ($page){
    case 'welcome' : include ('welcome.php'); break;
    case 'link' : include ('link.php'); break;
    case 'contact' : include ('contact.php'); break;
    }
    ?>
    </div>

    1- You must have these files first : welcome.php, link.php, contact.php
    2- when your user open your web site, welcome.php is automaticaly include in the main <div>
    3- if your user click on the link in the navigation bar, the link.php page is include in the main <div>, so replace the welcome.php
    4- the url of the link in you navigation is : <a href="index.php?page=link"></a>
    5- the url of the contact in you navigation is : <a href="index.php?page=contact"></a>
    6- index.php is the main file of your web site.

    Hope this could help you,
    -= Dweed-Ly =-

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you

    That worked exactly, pretty easy solution too!

    One more question, if the content that gets loaded has a link. Do I just add more cases or would it get more complicated than that?

    Say I load a page that displays thumbnails in the main area. If you click a thumbnail I'd want it to go to that persons profile, in the main area. Not good at grasping those type of concepts yet. Seems to me I'd have way to many if statements.

  • #4
    New Coder
    Join Date
    Mar 2004
    Location
    CAMBODIA
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One more question, if the content that gets loaded has a link. Do I just add more cases or would it get more complicated than that?
    Yes, in the index.php just add more cases as you would like and the link in the loaded page is :
    PHP Code:
    <a href="index.php?page=thumbnail">Thumbnail</a
    Good luck
    -= Dweed-Ly =-

  • #5
    New Coder
    Join Date
    Aug 2005
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Will it start getting more complicated as more links are created, some are dynamically created from php, like usernames and etc... Think template would be better?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •