Results 1 to 2 of 2

Thread: PHP One or many files?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    PHP One or many files?

    At the moment i have an unordered list which is my links to pages on my website. I have set up divs so i have the header, content, sidebar and footer sections.

    Now from what i am trying to get the content section will be the only section effected when page is changed all other sections will pretty much be ssi files if anything.

    I have a home page, image page and words page.

    Now as a user i might be on the home page and click on images link. Now my idea is to have a image gallery with items come up and depending on the results from the database.

    What i really want to know now is do i need a home.php and images.php or do i really just need the one home.php and depending on the users actions and mysql results the content section changes? The reason i ask is because the home page will be post like, images will be gallery based and the words will be just a passive formatted paragraph.

    I am sure there has to be a way to click on a link and instead of directing to a new php file it just reloads the present one and changes the content and the url as well (/words, /images, ...)

    Tried to explain everything i could before bed hope to have a response soon, if anyone needs me to clarify anything they don't understand i will!

    Any help or better ideas are appreciated!!! p.s i was going to call this thread "PHP 1..* files" but pretty sure that might've scared people off lol

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: PHP One or many files?

    there's a number of ways you can go about this...
    one is to have individual files for everything and each file is all inclusive with a header, nave and footer and all that.
    Another method is to slice up the page and included bits as needed. so you have an index.php (home), gallery.php, header.php, nav.php, footer.php... your index and gallery would then include header, footer and nav in the correct locations...
    Another method is to have a single index.php, and then content files, home, gallery, etc... your links would then look like index.php?p=gallery and then you would include the proper content file as needed...
    Yet another option is to go with AJAX, and dynamically load content into a div container... this is much like the previous option with the exception that there wouldn't be a page load...
    Any yet ANOTHER option is to go with a model framework like MVC that allows you to define different views & data and can be template driven... this takes a bit more work and forethought to put together.
    I'm sure there's other options, and probably options that are a combination of several of those options...


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

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



Click Here to Expand Forum to Full Width