Page 1 of 2 12 LastLast
Results 1 to 16 of 21

Thread: Quick and easy PHP help needed chaps

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

    Quick and easy PHP help needed chaps

    So the main aim for me is to make my website smaller by having minimal amount of pages but including just as much content. Now this is one technique I have seen yet am pondering how to do it properly.

    PHP Code:
    $page $_GET['page'];
    if ((
    $page == "home") or ($page =="")) {
    include(
    'news/news.php');
    } else if(
    $page == "about") {
    include(
    'includes/about.html'); 
    Now, i'm planning to use this for the pages which are basically staying static apart from the news page.

    http://www.kezzer.co.uk/

    There's my website so you can check it out. I've just done a quick design update, the header and nav bar have changed slightly but there's still more work to be done to it.

    The pages i'm planning to use the include() function on are every single one apart from articles, tutorials and reviews as these will be produced from the database which will be on a seperate page called article.php.

    Now the one question i had was, how the hell does it catch the URL by saying if (($page == "home"). how is "home" defined? Someone told me it does this by default? /me is lost

    I can't seem to find anything relating to it at all which is quite confusing.

    Help please

  2. #2
    Cable Guy Jonny M's Avatar
    Join Date
    Jul 2003
    Location
    Loughborough Uni
    Posts
    4,263
    Thanks
    0
    Thanked
    4 times in 1 post

  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    lmao, ah so that's how it works. doh! /me slaps forehead

    I didn't quite understand it although i read the tutorial ten times over. I'll get to work on it and see if i can actually get it to work ta for the heads up, i'll tell ya how it goes

  4. #4
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    ok i put the following code in my index page

    PHP Code:
    <?php
    $page 
    $_GET['page'];
    if(
    $page == "contact")
    {
    include(
    'includes/contact.html')
    }
    ?>
    And i got a parse error for those lines. I added the contact.html in the includes folder and i changed the URL to index.php&page=contact for the contact link.

    What went wrong?

  5. #5
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    argh there's me not error checking forgot the ;

    Ok so the page loads but click on the contact link

    /me is tired

  6. #6
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    lmao, just ignore me, seriously now, ignore me, delete the thread :X!!!

    i figured it out. /me slaps self 100 times

    >_<!!!!

  7. #7
    Furry Shorty's Avatar
    Join Date
    Jul 2003
    Location
    Manchester, UK
    Posts
    1,237
    Thanks
    1
    Thanked
    2 times in 2 posts
    PHP Code:
    switch ($_GET['page']) {
    case 
    'about':
    include(
    'includes/about.html');    
    break;
    case 
    'contact':
    include(
    'includes/contact.html');
    break; 
    default:
    include(
    'news/news.php');

    Using a switch is neater and you can just add more "cases" as you so need, without having to keep doing the old if/elseif/else statements all the time
    "In a world without walls and fences, who needs Windows and Gates?"

  8. #8
    Registered User
    Join Date
    Feb 2004
    Location
    Swansea UK
    Posts
    6
    Thanks
    0
    Thanked
    0 times in 0 posts
    i had been having problems with this for a while too. glad this thread came up

  9. #9
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    /me starts again

    lol, ye the switch looks a lot nicer.

  10. #10
    Cable Guy Jonny M's Avatar
    Join Date
    Jul 2003
    Location
    Loughborough Uni
    Posts
    4,263
    Thanks
    0
    Thanked
    4 times in 1 post
    [SIZE=1]Shorty, having some trouble with this m8:

    The code in my index.php reads:

    PHP Code:
        switch ($_GET['page']) { 
        case 
    'index'
        include(
    'index.inc');     
        break; 
        case 
    'stores'
        include(
    'stores.inc'); 
        break; 
        default: 
        include(
    'index.inc'); 
        } 
    And the URL to the page is http://www.jonny-m.net/dofe

    But there's an error coming up (Behind the header), and typing

    http://www.jonny-m.net/dofe/index.php?page=stores

    Doesn't do anything.

    What am I doing wrong? Probably something incredibly stupid.

    Thanks
    Last edited by Jonny M; 22-02-2004 at 11:14 PM.

  11. #11
    Cable Guy Jonny M's Avatar
    Join Date
    Jul 2003
    Location
    Loughborough Uni
    Posts
    4,263
    Thanks
    0
    Thanked
    4 times in 1 post
    Ah, sorted now.

    Forgot the

    <?php

    ?>


  12. #12
    Senior Member Nemeliza's Avatar
    Join Date
    Jul 2003
    Posts
    1,719
    Thanks
    1
    Thanked
    5 times in 5 posts
    lol all those little things, you see programming is the route of all evil.

  13. #13
    Furry Shorty's Avatar
    Join Date
    Jul 2003
    Location
    Manchester, UK
    Posts
    1,237
    Thanks
    1
    Thanked
    2 times in 2 posts
    Quote Originally Posted by Caged
    Ah, sorted now.

    Forgot the

    <?php

    ?>

    rofl..
    "In a world without walls and fences, who needs Windows and Gates?"

  14. #14
    Cable Guy Jonny M's Avatar
    Join Date
    Jul 2003
    Location
    Loughborough Uni
    Posts
    4,263
    Thanks
    0
    Thanked
    4 times in 1 post

  15. #15
    Furry Shorty's Avatar
    Join Date
    Jul 2003
    Location
    Manchester, UK
    Posts
    1,237
    Thanks
    1
    Thanked
    2 times in 2 posts
    Quote Originally Posted by Caged
    Aww mate, I've done worse. Trust me
    "In a world without walls and fences, who needs Windows and Gates?"

  16. #16
    Cable Guy Jonny M's Avatar
    Join Date
    Jul 2003
    Location
    Loughborough Uni
    Posts
    4,263
    Thanks
    0
    Thanked
    4 times in 1 post
    Heheh, I'm sure you have.

    What do you use for all this PHP coding anyway? I'm currently using EditPlus, but I thought maybe a better text editor designed to do PHP, which can do things like complete code for me etc would be a better option.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Quick and easy spare ribs
    By BoB_DoG in forum Kitchen and Cooking
    Replies: 1
    Last Post: 20-01-2004, 10:44 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
  •