Page 1 of 1

Making a file show different dbs-result?

Posted: Wed Feb 25, 2004 6:14 pm
by seide
What do I have to do in order to make a page/file show results based on something else than $id.

Lets say I got a file named: show.php and I got a mySQL table kalled "div"
with $id, $category, $text. Is'nt it possible to write an URL like:
http://www.mysite.domaine/show.php?category=dog
and make the file list everything under category dog and nothing else although $category may include cat, pig and so on?

Posted: Wed Feb 25, 2004 8:31 pm
by AVATAr
yep

1. grab the variable with $_GET['category']
2. make a sql query lije:

'select * from div where category ="'.$_GET['category'].'"'

3. execute the query and show the result using foreach statement

note: check the input with urldecode, addslashes, etc...

good luck