[thelist] [PHP/MySQL] building a select statement from a mutilple select field

Hassan Schroeder hassan at webtuitive.com
Wed Jul 27 13:30:08 CDT 2005


Jeremy Weiss wrote:

> I've got a multiple select form box that lists several cities ...

> The problem is, when multiple cities are selected, my sql statement comes out like:
> SELECT * FROM cba_condo WHERE ... AND city = 'Biloxi' AND city = 'Diamondhead' AND city = 'Gulfport' AND city = 'Lakeshore' ORDERBY price Desc;

I don't do much PHP, but you might want to look at generating your
statement like

... AND city IN ('Biloxi','Diamondhead','Gulfport','Lakeshore') ...

FWIW!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.




More information about the thelist mailing list