...

View Full Version : using the same .php file but have .php?id=prod01, prod02, etc..



AshleyQuick
12-22-2003, 11:50 PM
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

Nightfire
12-22-2003, 11:54 PM
The way many people use is


<?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

AshleyQuick
12-23-2003, 12:06 AM
I sorta get it. Now what does the href/link code look like?

Nightfire
12-23-2003, 12:12 AM
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.

SDP2006
12-23-2003, 01:13 AM
Originally posted by AshleyQuick
I sorta get it. Now what does the href/link code look like?


<a href="page.php?id=001">Link</a>

AshleyQuick
12-23-2003, 09:33 AM
Excellent, thanks all!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum