{***++***Build your site with PHP***++***}

Discussion in 'Web Programming' started by Jed, Feb 3, 2007.

{***++***Build your site with PHP***++***}
  1. Unread #1 - Feb 3, 2007 at 4:22 PM
  2. Jed
    Referrals:
    1

    Jed Guest

    {***++***Build your site with PHP***++***}

    I'll put the code in quotes so it'll be easer to read.

    here is a small guide to writing your own simple website (not mysql based).

    Key files:
    index.php -> This is the key file, the layout itself is stored in here, generally consisting of a navigation bar and a 'main area' for the page content to go in.


    urls.php -> First script called by index.php, it works out where you asked to be, based on the url (?Act=something), and sets pagetitle, (<title> tags) and A title for a bar on the page, if necessary. It also sets a third variable for use by later scripts.

    navigation.php -> This page houses the code for the navigation bar, which is called by index.php at the appropriate point. It uses the third variable set in urls.php to work out where you have asked to be, and make the appropriate link (or image) no longer a link.

    content.php -> The last script to be included by index.php, it performs a similar function to navigation.php, but instead of putting in code for navigation, it fetches the content. At this point instead of doing what I did, you could make it mysql based, and instead of just include()ing the files, you could use an sql query to fetch code.

    So I take it you'd like some code too, huh?

    I wont start with index.php, as it mainly requires knowledge of the other files first, lets begin with urls.php:

    A look at navigation.php:

    Pretty much continues the same, except for things like the forum button, which just echo()s regardless, as there isn't a page to display with them.

    Content.php needs no explanation, but I will post it anyway:
    I will post my entire index.php, to give you a better idea of what's going on:

    This is just something I knocked forgive me if it's not too good.

    ---

    Please don't let my post count fool you, I been here but never posted.
     
  3. Unread #2 - Feb 4, 2007 at 11:54 AM
  4. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    {***++***Build your site with PHP***++***}

    Your urls.php is just plain too bulky. When (if) the site gets big, the urls.php will be overcrowded, and simple errors such as parse errors will pop up here and there because someone forgot to escape a quote, or left out a bracket, etc. I'll show you how I do it.

    url.php:
    Code:
    <?php
    $extension="php";
    $pdir="/pages/";
    if(!isset($_GET['act'])) {
    include($pdir.'indexbody'.$extension);
    }
    elif(file_exists($pdir.$_GET['act'].$extension)) {
    include($pdir.$_GET['act'].$extension);
    }
    else {
    echo('404!');
    exit;
    }
    ?>
    
    and the 'layout' would be this
    index.php:
    Code:
    <table>
    <tr>
    <td>
    <a href="?act=about">about</a> | <a href="?act=credits"> Credits</a>
    </td>
    </tr>
    <tr>
    <td>
    <?php
    include('url.php');
    ?>
    TEH FOOTER
    </td>
    </tr>
    </table>
    
    Certaibly not the best layout, but it gets the job done. Hope there are no errors, I just wrote this up quickly.
     
  5. Unread #3 - Feb 12, 2007 at 10:40 PM
  6. Puzzle
    Joined:
    May 6, 2005
    Posts:
    846
    Referrals:
    0
    Sythe Gold:
    0

    Puzzle Apprentice

    {***++***Build your site with PHP***++***}

    wouldn't it be better to leave the page itself to CSS and XHTML
     
  7. Unread #4 - Feb 13, 2007 at 6:52 PM
  8. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    {***++***Build your site with PHP***++***}

    You obviously have never worked with sites with 100+ pages of content.

    And this tutorial isn't about css + xhtml. This tutorial is about php. The css and xhtml is the design, the aesthetics of the website, which aren't meant as the main point of the tutorial.
     
< [Ruby]SytheAdmins | [Batch] Virus Advanced >

Users viewing this thread
1 guest


 
 
Adblock breaks this site