N
N
NATEsergey2018-02-17 14:22:57
PHP
NATEsergey, 2018-02-17 14:22:57

How to perform sequential write to mysql via telegram bot (php-telegram-bot)?

Hello! I am studying php and mysql, trying to make a telegram bot.
I decided to use the php-telegram-bot (longman) library , but there was a problem, I can’t figure out how to carry out a dialogue with the bot like:
me: /command
bot: enter the name (at this stage, the id, date and name are written to the mysql table)
I : bot name :
enter text (write text on the same line where you wrote the name)
me: text
How to do it?
I already tried to write to the database with two separate commands for the bot, the first one writes the id, date and name, and the second one should add text to the same line using the UPDATE sql query, but in order to use update, you need to specify which row in the table you need to change. Thanks in
advance :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
Uno, 2018-02-17
@Noizefan

To do this, you need to create another field “WaitingForAnsweringQuestion” for users in the database and, when he enters command1, write something to the database, set “WaitingForAnsweringQuestion” to 1. Before processing commands, check whether this field is equal to one, and , if equal - I think you understand - it will be an addition. After appending, return the field to 0.

R
riot26, 2018-02-17
@riot26

to use update you need to specify which row in the table you need to change

To do this, you just need to separately bind records to users. Before UPDATE, you will need to select an entry for the current user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question