I think you are just using the wrong names for the $_POST values
The select is called minprice
and maxprice
and you are testing against $_POST['price']
which does not exist.
<select class="form-control" name="minprice" id="minprice">
<option value="">--Min Price--</option>
<?php
$args=array(':type' => 'general');
$sql='SELECT DISTINCT price FROM cars WHERE cartype=:type AND price !=" "';
$stmt=$pdo->prepare($sql);
$stmt->execute($args);
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
echo '<option value="'.$row['price'].'"'.($row['price']==$_POST['minprice'] ? ' selected="selected"' : '').'>'.$row['price'].'</option>';
// The correction is here ^^^^^^^
?>
</select>
And of course the same issue with maxprice dropdown
To get errors out of PHP even in a LIVE environment add these 4 lines to the top of any MYSQLI_
based script you want to debug
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
.
This will force any MYSQLI_
errors to generate an Exception that you can see on the browser as well as normal PHP errors.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…