Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using the same .php file but have .php?id=prod01, prod02, etc..

    What is the best method to have, for instance, products.php and then have links on that page that would click to the following url's:

    products.php?id=prod01

    products.php?id=prod02

    products.php?id=prod03

    ..the page would have the same html templates but the "content" area would change for each. Does this make sense?

    Ashley

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    The way many people use is
    PHP Code:
    <?php
    $id 
    $_GET['id'];

    if(
    file_exists($id.'.php')){
      include(
    $id.'.php');
    }else{
      echo 
    'File does not exist';
    }
    ?>
    It's not very secure, but it's a nice simple way to see how it's done without the use of a database

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I sorta get it. Now what does the href/link code look like?

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    What that basically does is see if a file exists that's in the id variable in the url (page.php?id=001). So for id=001, it will search for 001.php. If that file exists, it will include the file into your page.

  • #5
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by AshleyQuick
    I sorta get it. Now what does the href/link code look like?
    Code:
    <a href="page.php?id=001">Link</a>
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent, thanks all!


  •  

    Posting Permissions

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