Answer the question
In order to leave comments, you need to log in
How to display data from a table from MySql according to criteria using PHP?
This code displays only one field from the table. Can you tell me how exactly to make it so that all the data from the table is displayed by one key?
function getProduct($product_id){
global $db;
$query="select * from product WHERE cat_id=".$product_id;
$res=mysqli_query($db, $query);
$res=mysqli_fetch_assoc($res);
return $res;
}
case 'Бургеры': {
//$product_id=explode('_',$text )[1];
$product_id=1;
$product_info=getProduct($product_id);
$msg=" Наименование товара: "."<b>".$product_info['name']."</b>".PHP_EOL.PHP_EOL."Описание товара: ".PHP_EOL.$product_info['description'].PHP_EOL.PHP_EOL."Цена (тг.): "."<b>".$product_info['price']."</b>".PHP_EOL.PHP_EOL;
if($product_info['photo_link']!=null){
$msg.="<a href='".$product_info['photo_link']."'></a> @".$bot_username;
}else{
$msg.=" @".$bot_username;
}
//message($chat_id, $product_info['photo_link']);
message($chat_id, urlencode($msg).inline_btn(array(' Добавить в корзину ','/addToCart_'.$product_id)),null,'HTML');
}break;
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