Pick link from database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
EagerWolf
Forum Newbie
Posts: 1
Joined: Mon Jul 03, 2006 5:14 pm

Pick link from database

Post 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!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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';
(#10850)
Post Reply