Page 1 of 1

Pick link from database

Posted: Mon Jul 03, 2006 5:24 pm
by EagerWolf
Hello!

Well what I want to do can be easil explained by exampel:

1. I have list of hotels from New York, Los Angeles, Las Vegas, Tokyo, Berlin, London
2. I have list of motels from New York and Berlin

So I want to do that my PHP script will look which cities are included in database.... If city is included, I'd like to list it as an option to select.

If user selects Hotels, than on site should be listed New York, Los Angeles, Las Vegas, Tokyo, Berlin, London.
If user selects Motels, than on site should be listed New York and Berlin.

In case any new city is added, script automaticly add new City as an option to select in form.

How should I solve this problem?

Thanks for your help!

Posted: Mon Jul 03, 2006 5:52 pm
by Christopher
I don't know what your data looks like, but here is the general idea.

For the list of cities with hotels:
SELECT DISTINCT city FROM mytable WHERE type='Hotel';

For the list of cities with motels:
SELECT DISTINCT city FROM mytable WHERE type='Motel';