Re: [PHP-DB] Re: ORDER BY question
Hi Chris, Did you get a useable answer to this? > Using PHP and MySQL, how can I do an ORDER BY where city = $city? What > happens is this, I have a search engine which works nicely, but I want to > bring up the closest matches to the search first at the top, how can I do > this? > > Say you enter Munich Hotels, I want all entries with Munich Hotels to appear > first before the rest, any ideas? Try: SELECT ... ORDER BY city="Munich Hotels", city; The first 'column' in the ORDER BY clause evaluates to TRUE or FALSE, and thus puts Munich Hotels (TRUE) above everything else (FALSE), and within those two groupings city is sequenced into alpha ASC (meaningless for the M-Hotels grouping because they all have the same city value). Ok? =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ORDER BY question
Good article on phpbuilder.com Slapping together a search engine for your database is easy with PHP and MySQL http://phpbuilder.com/columns/clay19990421.php3 [ p i x e l p e t e r ] [EMAIL PROTECTED] "Chris Payne" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 000c01c1bb1c$e049dce0$0200a8c0@chris">news:000c01c1bb1c$e049dce0$0200a8c0@chris... Hi there everyone, Using PHP and MySQL, how can I do an ORDER BY where city = $city? What happens is this, I have a search engine which works nicely, but I want to bring up the closest matches to the search first at the top, how can I do this? Say you enter Munich Hotels, I want all entries with Munich Hotels to appear first before the rest, any ideas? Thanks everyone. Chris Payne http://www.planetoxygene.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php