Hi,
I have a little problem. I have a website which I need to collect information from the database and present it. I’m using the same code I have on another page, with a few changes.
Here’s what I have:
// The query
$sql = "SELECT * " .
" FROM `table`".
" WHERE `this_address` LIKE '%$area_s%'".
" AND `this_bedrooms` = '$beds'".
" AND `this_price` <= '$maxprice'".
" AND `sale` = '1'".
" ORDER BY `$sort` $order".
" LIMIT $limitvalue, $limit";
// Trying to find the problem
echo mysql_num_rows(mysql_query($sql));
echo $sql;
// The num rows returns the correct number
// The query is correct, tried in phpMyAdmin and results were correct
// Create a list
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$id = $row["this_id"];
$number = $row["this_number"];
$address = $row["this_address"];
$postcode = $row["this_postcode"];
$details = $row["this_details"];
$bedrooms = $row["this_bedrooms"];
$price = $row["this_price"];
$image = $row["this_image"];
echo "all the info etc";
//PROBLEM: Only the first 2 results are displayed.
}
Can anyone see the reason only 2 results are displayed?
SELECT * FROM table WHERE this_address LIKE ‘%%%’ AND this_bedrooms = ‘1’ AND this_price <= ‘500000’ AND sale = ‘1’ ORDER BY this_price ASC LIMIT 0, 5
The query works perfectly when run from phpMyAdmin.
I’ve also found the 2 results that do display have prices of 185 and 290, where as all of the undisplayed have prices around 180000. The field is set a DECIMAL, but I can’t see any problem with the DB setup if the query runs from PHPMA.
Also if I order by price DESC, no results are displayed (unless in PHPMA).
Something I just noticed, after the second list item is displayed, the rest of the page is cut off. That is, anything following the while loop is not displayed.
Still have no ideas though.