Re: sql problem or logic problem?
| From: | Web Admin | Date: | Sat, 07 Oct 2000 15:22:25 +0000 |
| Subject: | Re: sql problem or logic problem? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19042@lists.php.net to get a copy of this message | ||
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)
>
>
>