Answer the question
In order to leave comments, you need to log in
How to correctly display different templates on the page?
There is a table with products, which has the following structure:
|ID |NAME |COUNT |PROVIDER |DATEOFPURCHASE |CATEGORY
|1 |Банан |20 |Иван |2007-01-01 |Fruits
|2 |Помидор |500 | |2001-01-01 |Vegetables
|1 |Телефон |2 |Альбинос | |Phone
$category = $_POST['category'];
$stock_list = [];
$stock_view = $dbpdo->prepare("SELECT * FROM products
WHERE count > 0
AND category = ?
ORDER BY id DESC");
$stock_view->execute([$category]);
if($stock_view->rowCount()>0) {
while ($row = $stock_view->fetch(PDO::FETCH_BOTH)) {
//заполняю массив
$stock_list[] = [
'id' => $row['id'],
'name' => $row['name'],
'count' => $row['count'],
'provider' => $row['provider'],
'date' => $row['DATEOFPURCHASE']
];
}
//далее отправляю массив в шаблон
echo $tpl = $twig->render('page/tpl.twig', $stock_list);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question