www.webdeveloper.com
Results 1 to 1 of 1

Thread: Nested Includes to Database

  1. #1
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,703

    Nested Includes to Database

    I've got a page ( http://coachrandom.furtopia.org/chronology.php ) that uses what I guess you could call "nested includes". What I'm trying to do is set up a page that uses the database instead of nested includes.

    Here's what I mean by nested includes. This is the code for the page http://coachrandom.furtopia.org/chro...ster=1&month=2 :

    Main page:
    PHP Code:
    <?php
    include("./inserts/head.htm");
    echo(
    '<link type="text/css" rel="stylesheet" href="./CSS/setup.css">');
    echo(
    '<link type="text/css" rel="stylesheet" href="./CSS/listing.css">');
    $inserts=array("./chronology/semester0.htm","./chronology/semester1.htm""./chronology/semester2.htm""./chronology/semester3.htm""./chronology/semester4.htm""./chronology/semester5.htm""./chronology/semester6.htm""./chronology/semester7.htm");

    $max count($inserts); // get total inserts
    $i = (isset($_GET['semester'])) ? $_GET['semester'] : 0;
    include 
    $inserts [$i]; ?> 


    <div id="right">
    <h2>The Strips</h2>
    <li><a href="./chronology.php?semester=0">First Strips</a></li>
    <li><a href="./chronology.php?semester=1">Semester 1</a></li>
    <li><a href="./chronology.php?semester=2">Semester 2</a></li>
    <li><a href="./chronology.php?semester=3">Semester 3</a></li>
    <li><a href="./chronology.php?semester=4">Semester 4</a></li>
    <li><a href="./chronology.php?semester=5">Semester 5</a></li>
    <li><a href="./chronology.php?semester=6">Semester 6</a></li>
    <li><a href="./chronology.php?semester=7">Later strips</a></li>

    <h2>Random Stuff</h2>
    <ul>
    <li><a href="./storylines.php">Storylines</a></li>
    <li><a href="./subjects.php">Subjects</a></li>
    <li><a href="./index.php">Home</a></li>
    </ul>
    </div>
    <div id="bottom">All strips here are copyright Alexander Scott Ruhl, and were published in the Cavalier Daily between 2001 and 2005.  All rights reserved.  Please do not distribute these strips without written permission from Scott Ruhl or the Cavalier Daily.</div>
    </body>
    </html>
    First Include (semester1.htm)
    HTML Code:
    <link type="text/css" rel="stylesheet" href="./setup.css">
    <title>Semester One</title>
    </head>
    <body>
    
    <div id="top">
    <h1>Semester One</h1>
    <h2>August 29 - November 30, 2001</h2>
    </div>
    <div id="wrapper">
    <div id="left">
    <ul class="month4">
    <li><a href="./chronology.php?semester=1&month=0">August<br>Strips 4 - 6</a></li>
    <li><a href="./chronology.php?semester=1&month=1">September<br>Strips 7 - 24</a></li>
    <li><a href="./chronology.php?semester=1&month=2">October<br>Strips 25 - 43</a></li>
    <li><a href="./chronology.php?semester=1&month=3">November<br>Strips 44 - 60</a></li>
    </ul>
    <hr>
    [PHP]<?php
    $inserts=array("./chronology/sem-1/month0.htm","./chronology/sem-1/month1.htm", 
    "./chronology/sem-1/month2.htm", "./chronology/sem-1/month3.htm");
    $max = count($inserts); // get total inserts
    $i = (isset($_GET['month'])) ? $_GET['month'] : 0;
    include $inserts [$i]; ?> [/PHP]
    </div>
    </div>

    Second (nested) include (month=2)

    HTML Code:
    <h3>October</h3>
    
    <ul class="comiclist">
    <li class="left"><a href="./chronology/comics/comics.php?page=23">Comic 25<br>Character Design</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=24">Comic 26<br>You're Toast!</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=25">Comic 27<br>Challenges</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=26">Comic 28<br>Acorn Boy</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=27">Comic 29<br>Character Box</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=28">Comic 30<br>Homework</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=29">Comic 31<br>Fritos</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=30">Comic 32<br>Bad Influence</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=31">Comic 33<br>Won't Be Pleasant...</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=32">Comic 34<br>Fart</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=33">Comic 35<br>Brownies</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=34">Comic 36<br>Nightlatch, The Frog Pimp<br>(Strip 1)</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=35">Comic 37<br>Nightlatch, The Frog Pimp<br>(Strip 2)</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=36">Comic 38<br>Nightlatch, The Frog Pimp<br>(Strip 3)</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=37">Comic 39<br>Nightlatch, The Frog Pimp<br>(Strip 4)</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=38">Comic 40<br>Nightlatch, The Frog Pimp<br>(Strip 5)</a></li>
    <li class="left"><a href="./chronology/comics/comics.php?page=39">Comic 41<br>Into girls?</a></li>
    <li class="right"><a href="./chronology/comics/comics.php?page=40">Comic 42<br>Sucker!</a></li>
    <li class="center"><a href="./chronology/comics/comics.php?page=41">Comic 43<br>Buccaneers</a></li>
    </ul>
    What I want to be able to do is to take the different includes, and turn them into one single PHP file. As far as I know, that can be done using nested while loops (thank you Programming and Logic) The following are basically what the nested loops will have to include:

    1. Semester 0
      • (No monthly includes)
        • Comics 1-3
    2. Semester 1
      1. August 2001
        • Comics 4-6
      2. September 2001
        • Comics 7-24
      3. October 2001
        • Comics 25-43
      4. November 2001
        • Comics 44-60
    3. Semester 2
      1. January 2002
        • Comics 61-70
      2. February 2002
        • Comics 71-90
      3. March 2002
        • Comics 91-98
      4. April
        • Comics 99-115
    4. Semester 3
      1. August 2002
        • Comics 116-117
      2. September
        • Comics 118-137
      3. October
        • Comics 138-156
      4. November
        • Comics 157-175
      5. December
        • Comics 176-178


    And so on...

    Note that Semester 3 has FIVE months, not four, so that will have to be taken into account. Semesters 0 and 7 have no monthly inserts, since there are so few comics in those two "semesters" (Semester 0 contains 3 test comics and semester 7 contains censored comics and guest strips by Scott Ruhl), but that can be dealt with easily.

    Anyways, the question is, how do I do this?
    Last edited by Mr Initial Man; 12-11-2005 at 06:12 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles