Results 1 to 8 of 8

Thread: 100% Database driven website

  1. #1
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts

    100% Database driven website

    One thing i have always wondered about is how this is achieved.

    I know the basics of PHP and MySQL and I use a database with many tables in it for my website. The thing is, i don't understand how people make their website completely database driven. Do you create tables for every page? It seems to be very confusing. It would be extremely handy for me to do this time around because I found out that the mac version of IE doesn't display my website properly which means i need to re-do every page. It would be better if it just put the data into a template.

    Can anyone help please?

  2. #2
    Senior Member Shad's Avatar
    Join Date
    Jul 2003
    Location
    In front
    Posts
    2,773
    Thanks
    22
    Thanked
    40 times in 24 posts
    The trouble with DB driven pages is that they are slow. It's more costly to make a connection to a database, open a query, read some data and send it to the browser, than just open a text file and send that to the browser.

    What you can do is create a generic page template with a 'gap in the middle' where the page content goes. Then you would have a table of page records. Each record would have a unique reference, and maybe some misc info like the page title, a general heading, etc.

    Then you could have another table containing page items. Each record would have a unique reference, as well as a 'pointer' to the page (i.e. the page reference of the page that the item is displayed on). It would also contain the data for the item.

    Then as I'm sure you've spotted by now, it's just a case of loading a page and then loading all of the data items which have a page reference of your page. Following me still?

    This is in principle a very basic content management system. If the content isn't going to be changed very often, it would be worthwhile dumping a complete page to a cache file and then questioning the existence of a cache file before building each page. This saves costly database trips.


    Any questions...?
    Simon


  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Wouldn't that mean a page full of mysql saying "if link clicked display so and so?"

    I'm finding it quite hard to understand it all at the moment. I haven't even created an admin system for my site 'cause i don't know how to so i'm using the myadmin to do it all :/

  4. #4
    Senior Member Shad's Avatar
    Join Date
    Jul 2003
    Location
    In front
    Posts
    2,773
    Thanks
    22
    Thanked
    40 times in 24 posts
    Code:
    pagenum = Request.Querystring("pg")
    If isnumeric(pagenum) then
      'open connection
      'run query
      'print page
    Else
      Response.Redirect("thispage.asp?pg=0")
    End if
    It's ASP but the idea's there. You run a query based on a number passed in the query string. No need for lots of 'if' statements.
    Simon


  5. #5
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    ah ha. I understand it, it's just doing it which is the hard part. So would i create a table for the pages then? Where would the content be stored for the pages which haven't got tables such as the index page and so on?

  6. #6
    Senior Member Shad's Avatar
    Join Date
    Jul 2003
    Location
    In front
    Posts
    2,773
    Thanks
    22
    Thanked
    40 times in 24 posts
    Sounds like you're not quite up to speed with database theory.

    A table contains n records. For each page on your website, I am suggesting you have a record in a table. Similarly, for each item of content on a page, there could be a record in another table storing the content.

    So you end up with 2 tables for your website. One houses pages, the other houses content.
    Simon


  7. #7
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    blimey, i really do need to do some more reading!

    On my website i have a few tables. One for articles, one for reviews and one for tutorials. These display the content depending on the category. I've also got a table for the news. That's all i have for the database.

  8. #8
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    you could merge those together in one table and have an "article_type" field..

    ex:
    article_no(primary) | article_type | content


    Then you can pull back all the articles for type "news" etc
    Last edited by Stoo; 18-01-2004 at 02:07 PM.
    (\__/)
    (='.'=)
    (")_(")

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. hexus database
    By ingouk in forum HEXUS Suggestions
    Replies: 4
    Last Post: 08-09-2003, 09:46 PM

Posting Permissions

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