Hi I wonder if anyone can help, I would like to know how it's possible to do this;

Basically what I want to do is on my website have index.php, which will be a splash/enter page basically (html), which will go to a page called home.php, and as I'm going to be having sections, i.e; home, which will contain pages that are included in that section, that it would be more constructive and simpler to have those pages all in 1 section, with a single include to control elements for that section.

For example, on my website, I am doing a section that will basically cover pages relating to shops, bars, clubs, pubs etc that are in my hometown, which is what my website is based on. So for example, if I wanted to look at pharaohs nightclub.

I would have in the folder places, several files;

shops.php, pubs.php, clubs.php etc

In my example, pharaohs would be like this;

http://www.domain.com/places/clubs.php?page=pharoahs

and orchards brewery, would be like this;

http://www.domain.com/places/bars.php?page=orchards

How would I accomplish this? I have seen lots of websites use this schema for their addresses, but I don't know how to do it! Can someone please give me a straight answer, no asking why would I do it like this or whatever, just please tell me what I want to know! lol Basically I want to put the code for each club and pub all in their respective files and call on the individual pages for each from that 1 file via the url for each. If you get what I mean.

Cheers

    If the layout of the pages is similar, I might be inclined to put them on ONE page and address it somehting like this:

    http://www.domain.com/places/search.php?page=club&club=pharoahs

    THen you would just have PHP collect the variables, create a sql string to search the database for the information requested, then populate the display page with the results.

      No I want it simple, I don't want the variables to come from a database lol, I'm sure I have seen something similiar to this somewhere;

      • clubs.php

      code to define the page variable i.e; pharoahs

      // the code for pharoahs page

      code to define the next variable i.e; mercury

      // code for mercury page

      and so on...., the page for each displayed by visiting the url clubs.php?page=pharoahs or mercury.

      I'm sure it's something similiar like this, the sql url seems a little too complicated and doesnt look as proffessional as the one I'm after, but I'm not just wanting to use it because its cool, it makes it easier for me to have the structure of the pages in that 1 file, and have variables in an externaly included file, so I only have to edit 1 or two files to change the entire look and design of the section.

      Plus it makes things easier for anyone else that comes onto the project especially if its all commented etc.

      So can you help or what? lol

        It's your page, you can do it any way you want, but the structure looks anything but simple to me. If I have more than a couple dozen pages I start losing them lol

        So, you are planning on building a seperate static page for each club? I guesss the cleanest way would be to have a switch statement on clubs.php something like this:

        <?php
        $page=$HTTP_GET_VARS['page'];
        
        switch($page){
            case 'pharoahs':
            	include 'pharoahs.html';
        	break;
            case 'murcury':
            	include 'murcury.html';
        	break;
            default:
            	include 'notfound.php';
        }
        ?>
        

          I wont get them lost, trust me, I'll comment everything <G> Just tell me what I need to do...

          Do I do it like this?

          
          <?php
          $page=$HTTP_GET_VARS['page'];
          
          switch($page){
          
          case 'pharoahs':
          // pharoahs code here
          break;
          
          case 'mercury':
          // mercury code here
          break;
          
          default:
          include 'notfound.php';
          }
          ?>
          
          

          Is that the general idea of it?

            lol no, i have figured it anyways and got it working, basically what i was after is finding a way of having a bunch of pages in 1 php file, and calling on the individual pages with the url, like this;

            <?php
            $page=$HTTP_GET_VARS['page'];
            
            switch($page){
            
            case 'pharoahs':
            // pharoahs code here
            echo(" Page pharoahs ");
            break;
            
            case 'mercury':
            // mercury code here
            echo(" Page mercury ");
            break;
            
            case 'test':
            // test code here
            echo(" Page test ");
            break;
            
            default:
            // default code here
            echo(" Page default ");
            
            }
            ?>
            

            And it works! Try it!

            Thanx for your help MrAlaska!

              Originally posted by mwood_2k2
              Do I do it like this?

              That way would work but it would be a mess, which might appeal to you G

              The code I first posted would work as written, it would just suck in whatever page it was supposed to, then you would put the code for each page it it's own HTML file. Doing it the the way you modified it is an alternative. There are a ton of other alternatives, also. If you REALLY want the code to be all on one page, I would put them inside of IF-ELSEIF conditions instead of the switch statement just to make it look a little cleaner.

                Actually that pretty much works for me the way I've modified it, I'm thinking about other people, when I take other people on board to help develop the site I think it would just be more readable for them this way, it's easy for me, having all the pages of the particular section in 1 file doesnt look messy to me :-]

                In fact it looks quite structured the way I modified it G

                Besides doing it the way u suggested defeats the point of 1 of the reasons I want it this way, to cut the number of files to a minimum! lol.

                It will look (to an outsider of my site when they come on the team and try to edit it) messier than the code when there are about 20 files, each with a page for the club, when they come to edit that, its a lot of work, so its better to have them all on 1 file, with an included file that contains an array with all the variables, which are called upon in the actual page areas of the page that displays the club pages. If I did it your way, my page would have to include the individual pages, which for me to have good control would mean having an include in them for components of the pages. So doing it your way, creates a 3 level heiarchy, whereas mine is simple, and only has a 2 level heiharchy and allows me to control my pages better, and anyone else.

                So tell me, which is simpler now? lol

                  Write a Reply...