I have a large database of items, and each has a unique ID. I would like to achieve the following: If a user wants to find out information on item 3563, he can do so by accessing the URL http://domain.com/item/3563/. If he wants to find information on item 3565, he can do so by accessing http://domain.com/item/3565/. How can I achieve this? (If it helps, I would like to have something similar to how WordPress displays posts [it finds the entry in the database and shows it, even though there is no actual file with the name as the URL])
build a page with a $_GET parameter then do a mod_rewrite for in the page make a query like select * from tblName where id = '".mysql_real_escape_string(addslashes($_GET['id'])."'
Thank you, crivion and harris - I got it working. For other webmasters who want to know how to do it, I found this page very helpful: http://www.workingwith.me.uk/articles/scripting/mod_rewrite
Pseudo rewrite code: "^/item/([0-9]+)/" => "item.php?id=$1" Code (markup): item.php file: // require_once('dbconnector.php'); // connect(); $id = $_GET[id]; if(!is_numeric($id)) { die('invalid id'); } $select = mysql_query("SELECT * FROM table WHERE id = '$id' LIMIT 1"); while($row = mysql_fetch_assoc($select)) { //process all in here ($row[table_row_name]) } PHP: I hope this helps.