R
R
redesupar2021-04-06 10:24:52
PHP
redesupar, 2021-04-06 10:24:52

Additional buttons after pressing the button and output from the data database in the bot?

I write a telegram bot using https://github.com/TelegramBot/Api

$bot->command('start', function ($message) use ($bot) {
    $keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup(
        [
            [
                ['callback_data' => 'balance', 'text' => 'Баланс карты'
                
            
                ],
                ['callback_data' => 'quantity', 'text' => 'Наличие товара']
            ]
        ]
    );

    $bot->sendMessage($message->getChat()->getId(), "Добро пожаловать", false, null,null,$keyboard);
});
if($data == "balance"){
    $bot->sendMessage($chatId, "Напишите номер карты");
    $bot->answerCallbackQuery($callback->getId()); 
}
    if($data == "quantity"){
    $bot->sendMessage($chatId, "Напишите штрих-код продукта");
    $bot->answerCallbackQuery($callback->getId()); 
}

Questions such

as 1 how can I call the function in PHP in the button display the balance so that it gets the number, searched in the database and sent the balance if there is no such card echo "Card data not found"
function get_udata($balance){
     global $db;
     $res = array();
     $balance = mysql_real_escape_string($balance);
     $result = mysql_query("select * from `balance` where card='$balance'",$db);
     $arr = mysql_fetch_assoc($result);
     if(isset($arr['data_json'])){
         $res = json_decode($arr['data_json'], true);
     }

     return $res;
 }

How can I display another button with the choice of the city after pressing the button for the availability of goods, and only then the barcode? and to also pass the city and the barcode to the function?

php

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question