Php, One By One

Discussion in 'Gaming' started by XMasterX, Oct 2, 2005.

  1. XMasterX

    XMasterX Well-Known Member

    Age:
    40
    Posts:
    5,336
    Likes Received:
    0
    Joined:
    Aug 1, 2005
    Location:
    Wisconsin, USA
    Ok, I am going to create a site, and want to use PHP, yet I do not know much about it, and the tutorials are not helping me.

    I am more of a 'look and play' person. I don't and can't follow tutorials, and I don't learn as fast. But I can view code, with comments, mess with it, see what it does, and in the end, I learn more...

    So, I want to start out with:

    1. A banner that shows up in every page
    2. A navigation bar that shows up in every page

    and maybe have those on seperate pages, or the same page so I only have to edit it once... not 1000 times like with html.... :P
     
  2. Toc

    Toc Member

    Posts:
    13
    Likes Received:
    0
    Joined:
    Oct 2, 2005
    The one you want is easy. Go to php.net and look up
    Code:
    include()
     
  3. Andrew

    Andrew Well-Known Member

    Age:
    37
    Posts:
    7,617
    Likes Received:
    0
    Joined:
    Mar 10, 2005
    Location:
    California; Texan lost in Cali
    +rep isn't currency, i've edited your post to reflect that.
     
  4. XMasterX

    XMasterX Well-Known Member

    Age:
    40
    Posts:
    5,336
    Likes Received:
    0
    Joined:
    Aug 1, 2005
    Location:
    Wisconsin, USA
    I can rep anyone that helps me, and you cant stop me.... well, you technically can if you stop me from repping, but anyway, I can rep who I feel really helped me...

    I'm not doing it in a matter of currency, I'm just doing at as a friendly person...
     
  5. XMasterX

    XMasterX Well-Known Member

    Age:
    40
    Posts:
    5,336
    Likes Received:
    0
    Joined:
    Aug 1, 2005
    Location:
    Wisconsin, USA
    Ok, now if anyone can help me make the nav bar on the left side, like most websites do, please help.

    I think that you would just post it in a table, and put it on the left side of the table, I dont know exactly...
     
  6. Daz

    Daz Well-Known Member

    Age:
    38
    Posts:
    1,024
    Likes Received:
    0
    Joined:
    Nov 5, 2004
    Location:
    UK
    I am a lazy php developer, feel free to contact me on msn [email protected]

    Normally on time from uk evenings/early mornings (like 8pm-2am sorta thing)

    :P Daz
     
  7. Daz

    Daz Well-Known Member

    Age:
    38
    Posts:
    1,024
    Likes Received:
    0
    Joined:
    Nov 5, 2004
    Location:
    UK
    *double post soz

    BTW hes right just i

    include(''); :P Daz
     
  8. XMasterX

    XMasterX Well-Known Member

    Age:
    40
    Posts:
    5,336
    Likes Received:
    0
    Joined:
    Aug 1, 2005
    Location:
    Wisconsin, USA
    yeah, Toc talked to me on msn. we got the banner part done.
     
  9. LemoNade

    LemoNade Well-Known Member

    Age:
    37
    Posts:
    500
    Likes Received:
    0
    Joined:
    Dec 21, 2004
    Location:
    Southampton, England
    Ok, the basics of how I would make a page using PHP-Includes:

    First make a new file (index.php) in dreamweaver and do all the HTML of how you want the layout of the frontpage (and all the other pages). As far as the content area is concerned, put the following code where you would want all the content to show up:

    Code:
    <?php include($file) ?>
    What this is doing is telling the parser to include contents of a variable - $file. Now as I'm sure you've realised, this hasnt been set yet.

    Make a new file called header.php and it in put the following (get rid of any HTML so its blank first):

    Code:
    <?php
    switch($HTTP_GET_VARS['page']) {
    
    case '':
    $file = 'home.php';
    break;
    
    case 'contact':
    $file = 'contact.php';
    break;
    
    }
    ?>
    You dont really have to understand this code, but basically its checking for an HTTP variable (i.e. index.php?page=content) and then setting the variable $file with the name of the appropriate file (i.e. home.php).

    Following me so far? ;)

    Next, go back to your index.php file and at the very top (above any HTML) put the following code:

    Code:
    <?php include("header.php"); ?>
    The final thing you have to do is page 2 files; 1 called home.php and 1 called contact.php. Put in any content (even if its just temporary) for a home and contact page in the corresponding file and upload it to a PHP-compliant webserver.

    To test it, go to www.yoursite.com/yourfolder/index.php and hopefully you will see your page design and in the content area you should see the content you put for the homepage. To see the contact page, go to www.yoursite.com/yourfolder/index.php?page=contact and you should see your contact page content in the content area :)

    Hope this made sense and even if you dont know much PHP you should be able to modify it accordingly to work with other pages.

    Feel free to post if you have any questions.
     
  10. XMasterX

    XMasterX Well-Known Member

    Age:
    40
    Posts:
    5,336
    Likes Received:
    0
    Joined:
    Aug 1, 2005
    Location:
    Wisconsin, USA
    Thanks. I have a small programming background, so I understand how things need to be called before they can be used...

    [edit] My 901st post!!!![/edit]
     

Share This Page