Making a file show different dbs-result?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
seide
Forum Newbie
Posts: 1
Joined: Wed Feb 25, 2004 6:14 pm

Making a file show different dbs-result?

Post 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?
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post 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
Post Reply