Answer the question
In order to leave comments, you need to log in
How to display records without repetition?
Good day to all! There is a question:
There is a request of the following form
$stmt = $pdo->query('SELECT price FROM middle_price');
$price = $stmt->fetchAll();
return $price;
<span class="filter_name"><?php
if ($price['price'] <= 250) {
echo 'до 250';
} else if ($price['price'] >= 250) {
echo '250-500';
}
?></span>
Answer the question
In order to leave comments, you need to log in
SELECT
CASE
when price < 250 then 'до 250'
when price between 250 and 500 then 'от 250 до 500'
ELSE price
END as price
FROM middle_price
else if in my opinion should be merged, in your case you don’t need to use elseif at all
<span class="filter_name"><?php
if ($price['price'] <= 250) {
echo 'до 250';
}
if ($price['price'] >= 250 and $price['price'] <= 500) {
echo '250-500';
}
?></span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question