patrickm Posted December 13, 2006 Share Posted December 13, 2006 Being new to the world of PHP and MySQL,I have a problem for which I can't think of an answer.At the moment I am creating a website on which there will be a database with several companies in it.What I want to create is a dropdown selectionmenu (using < s e l e c t > and < o p t i o n >) with all cities from the companies on the database in it.But the problem is that several different companies are located in the same city.So using SELECT from the cities-table will result in a (faulty) list with double/triple cities on it.My question: how do I select and sort out the cities and create a list on which each city is listed only once?Any help would be more than welcome 8) Quote Link to comment https://forums.phpfreaks.com/topic/30489-solved-select-from-database-using-data-from-the-database/ Share on other sites More sharing options...
Cagecrawler Posted December 13, 2006 Share Posted December 13, 2006 The MySQL query should be:[code]SELECT DISTINCT column FROM tablename[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30489-solved-select-from-database-using-data-from-the-database/#findComment-140365 Share on other sites More sharing options...
patrickm Posted December 13, 2006 Author Share Posted December 13, 2006 Ouch ....And I thought it would be more difficult :-[Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/30489-solved-select-from-database-using-data-from-the-database/#findComment-140387 Share on other sites More sharing options...
daniel244rock Posted December 14, 2006 Share Posted December 14, 2006 Wow, I've been doing the MySQL thing for years and haven't had to know that, so I didn't know that. Thats really handy, thanks for the answer Cagecrawler and thanks for asking Patrickm.Daniel Quote Link to comment https://forums.phpfreaks.com/topic/30489-solved-select-from-database-using-data-from-the-database/#findComment-140763 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.