Results 1 to 4 of 4

Thread: creating first dynamic page

  1. #1
    Join Date
    Apr 2007
    Location
    Sydney, Aust - Downunder
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default creating first dynamic page

    i have one php page called states.php

    within states.php there are many subpages Eg: states.php?nsw and states.php?qld

    how do i create such a page where the content is broken up into sections by php vars.

    Regards

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Code:
    http://www.example.com/states.php?page=nsw
    PHP Code:
    <?php

    if($_GET['page'] == "nsw"){
         
    // "nsw" content; with the url above, this content is what the user would see
    }elseif($_GET['page'] == "qld"){
         
    // "qld" content
    }else{
         
    // default content (if there is no valid page id in url)
    }

    ?>
    really basic, but that's the idea. They're not variables, but conditional statements based on $_GET information from the url.

  3. #3
    Join Date
    Apr 2007
    Location
    Sydney, Aust - Downunder
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks so much for the reply. no wonder my google search was prooving to be difficult - as i wasnt searching for the right thing.

    this easy fix was all i was after.

    kind regards traq

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    no problem. if that's all you need, go back to your first post and click edit > go advanced and set your thread title prefix to "Resolved". glad I could help!

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
  •