SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple PHP question

    Hey

    I have been coding PHP/MySQL stuff for a while, and having heaps of fun with it (thanks Kevin...)

    My question is this (and forgive me if it is longwinded and confusing!) [and I have had a look around a load of sites and can't seem to find a good tutorial on this]...

    How do you create an article driven site?! I have seen loads of sites which have a page open with :

    blah blah blah blah [read more...] (e.g. sitepoint!)

    and links that look like this:

    www.something.com/articles/article.php?376

    or something. The question I think is really concerning the database behind it.

    Is there like one huge database that would have various fields containing the main text which is then simply inserted into article.php which formats accordingly? Or is it simply a table containing links to .html files (a la "jump start to easy urls article").

    Confused? I am. Any help!?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  2. #2
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well it depends on how the designer made it, some sites have a database of the files to be included so its somewhat automated, other sites will have it entirely from the database, and the usual is a included file thats placed in a template.

    If your asking as to HOW, thne thats complicated, here is sample code you can look at if it helps..

    PHP Code:
    if ($article) {
      
    // lookup the article and load it up
      
    $inc "/include_files_folder_path/".$article.".php";
      
    // double check someone didnt try to put a fake article in there and display a 404 page
      
    if (!fopen($inc)) {
        
    // Some hacker tried to lookup a non-existant article!
        
    $inc "/include_files_folder_path/404.php";
      }
    } else {
      
    // No article was given, so lets popup a default include page since nothing is actually there 
      
    $inc "/include_files_folder_path/404.php";

    I dont know if that works, but im pretty sure it does, all you have to do to include the file is wherever on the page you want it, put this...

    PHP Code:
    <? include($inc); ?>
    Thats only an example with static pages, if you wanted dynamic, just replace the inc with a database call and lookup, easy stuff really...give it a whirl

    Hope that helps
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  3. #3
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that (oh and sorry to see your website dying!) - I'm interested though in I guess the design of the database.

    Is the actual text of the article held in a table cell or is actually an entire page been displayed as normal but the link being called from the database?

    Last edited by weirdbeardmt; Jun 24, 2001 at 05:58.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  4. #4
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    usually its just a table...all preformatted content...just insert where needed

    you have the template page...and the area for the content empty...so you take a small chunk of premade cotnent...and just use that for every article...so you dont end up messing up the entire page if you make a mistake closing a tag...
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  5. #5
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That'll be it then.

    Any ideas where I can find some sample code so I can have a look at the dynamics of it?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  6. #6
    SitePoint Member
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yo Dude, you want it - You've got it.

    Go to http://www.phpnuke.org

    Peter J. Pierre
    CTE NetWorks.com
    http://www.cte-networks.com

    A working example of PHP Nuke is one of our sites:

    http://www.torontodowntown.net

  7. #7
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try looking at www.hotscripts.com and see how far you get.

    Sean


Bookmarks

Posting Permissions

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