comparing integers in mySQL query doesn't work
Posted: Fri Feb 27, 2004 4:42 am
hi, i have a problem comparing some integer values in query. i get no error but php "mysql_num_rows" always returns zero despite it shouldn't.
i need to do a search in table, filtering things like region, type, price etc. Filtrering things which have "=" in query works, but using "<" and similar fails to work.
here is a part of HTML form i use to set the filters
(the part that couses problems in the query):
the values are stored in variables and then this query is called:
when i select for example "100.000" as price, query returns nothing despite there are things in db with price lower than 100.000.
(the same happens with "const_area")
in "buy" table structure "price" and "const_area" are of type BIGINT.
i can't find out what is wrong, please help me if you can.
i need to do a search in table, filtering things like region, type, price etc. Filtrering things which have "=" in query works, but using "<" and similar fails to work.
here is a part of HTML form i use to set the filters
(the part that couses problems in the query):
Code: Select all
<select name="constarea" size="1">
<option value="0"> <?php if ($_SESSIONї'lang'] =="svk") { echo' zobraz všetky' ; } if ($_SESSIONї'lang'] == "eng") { echo' show all'; } ?>
<option value="30"> > 30 m2
<option value="50"> > 50 m2
<option value="100"> > 100 m2
<option value="200"> > 200 m2
<option value="500"> > 500 m2
</select>
</td>
</tr>
<tr>
<td align="left">
<span class="formstyle">
<?php
if ($_SESSIONї'lang'] == "svk") { echo'cena:'; }
if ($_SESSIONї'lang'] == "eng") { echo'price:'; }
?>
</span>
</td>
<td align="right">
<select name="price" size="1">
<option value="0"> <?php if ($_SESSIONї'lang'] == "svk") { echo' zobraz všetky'; } if ($_SESSIONї'lang'] == "eng") { echo'show all'; } ?>
<option value="500"> < 500 €
<option value="1000"> < 1.000 €
<option value="10000"> < 10.000 €
<option value="100000"> < 100.000 €
<option value="1000000"> < 1.000.000 €
<option value="1000001"> > 1.000.000 €
</select>Code: Select all
$query1 = "SELECT type,region,city,price,const_area,bedrooms,bathrooms,sm_pic1,short_desc_slovak,short_desc_english,sh ort_desc_spanish FROM buy WHERE type = $type AND region = $region AND (price < $price) AND (const_area > $constarea)";(the same happens with "const_area")
in "buy" table structure "price" and "const_area" are of type BIGINT.
i can't find out what is wrong, please help me if you can.