Re: sql problem or logic problem?

From: Date: Sat, 07 Oct 2000 15:37:31 +0000
Subject: Re: sql problem or logic problem?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19044@lists.php.net to get a copy of this message
At 06:52 PM 10/7/2000 +0330, Web Admin wrote: the way that you listed below crossed my mind...making the query string "modular" if you will....i'm just one of those people that afraid to try new things :-) - thank you for you help.. ~kurth
Hey Kurth, I read your code carefully. Change your code to something like this, and it will help you. It's actually a very very good tip for people who are querying with several conditions. I think PHP should create some easier commands becuase it's used very very widely. See the code below: $querystring="SELECT * from $series where "; if ($bathrooms) {$querystring=$querystring." and bathroom=$bathrooms); if ($bedrooms) {$querystring=$querystring." and bedroom=$edrooms); // and include the rest of your queires to append additional conditions to // your querystring, finally execute this: $result=mysql_query($querystring,$db); This way, you just send one unique query to database, and print the result. It reduces your code length to less than 1/5!! Give it a try! Good luck, -Ahmad Anvari Webiste Administrator Morva System Co. Ltd. http://www.morva.net ----- Original Message ----- From: "Kurth Bemis" <kurth@usaexpress.net> To: <php-general@lists.php.net> Sent: Saturday, October 07, 2000 6:20 PM Subject: [PHP] sql problem or logic problem? hey all.... i have written a search engine that searches a database and SHOULD return homes that match the search criteria....but - it dosent. it seems to get only one of the 4 criteria....the SQL queries look ok... give it a try at http://www.jrehomes.com/tvhc/search.php and the source is at http://www.jrehomes.com/tvhc/search.phps any help would be welcomed :-) ~kurth Kurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer kurth@usaexpress.net http://www.usaexpress.net/kurth ICQ - 6624050 Call Sign - N1TYW PGP key available - http://www.usaexpress.net/kurth/pgp Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net (http://www.distributed.net) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
Kurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer kurth@usaexpress.net http://www.usaexpress.net/kurth ICQ - 6624050 Call Sign - N1TYW PGP key available - http://www.usaexpress.net/kurth/pgp Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net (http://www.distributed.net)

« previous php.general (#19044) next »