Hi, I'm trying to print the apartments that are below the price I set, but it displays the contents of the entire table.
Entering the price is done from here:
http://localhost/yourName/users/57,000
the code for controller :
public function actionView($params){
if(is_numeric($params[0])){
$id=$params[0];
}
else {
$price=$params[0];
}
if(isset($price)){
$users=Users::getUsersByPrice($price);
require_once (ROOT.'/views/list_all.php');
return true;
}
the code for apartaments:
public static function getUsersByPrice($price){
$db= Database::getConnection();
$stmt= $db->prepare("SELECT * FROM flat WHERE price=:price < :price");
$stmt->execute([':price'=>$price]);
$users= $stmt->fetchAll(PDO::FETCH_ASSOC);
return $users;
}
What I have tried:
this is the first query, here it display the whole table
$stmt= $db->prepare("SELECT * FROM flat WHERE price=:price < :price");
$stmt->execute([':price'=>$price])
The second one i try is this:
$stmt= $db->prepare("SELECT * FROM flat WHERE price=:price = (SELECT MIN (price=:price) FROM flat ) ");
With this query it is displayed only colums id,Area,Complex,City,Price
This is the table:
id Area Complex City Price
0 71 Sarafovo Burgas 550.000
1 108 St Vlas St Vlas 47.000
2 105 Izgrev Burgas 121.000
3 58 Slaveykov Burgas 57.000
4 95 Slaveykov Burgas 82.000
5 65 Paradise Nesebar 65.000
6 109 Valley Sofia 78.000
7 45 Aura Sofia 103.000
8 168 Smirnenski Plovdiv 91.000
9 73 Tomov Plaza Plovdiv 47.000