Answer the question
In order to leave comments, you need to log in
How to output one number using a for loop?
For those who do not understand that I am implementing this in a bot, read the tags carefully :)
I'm tired of inventing .. maybe stupid, but I want to implement it like this:
if 'Далее' in text:
for i in range(2, 6): #Создала список чисел (для rowid)
#LIMIT 1 OFFSET 2 - получить 1 строку, начиная со 2 записи
#Определим общее кол-во записей выбранной категории
connect_cursor.execute(f'''SELECT Ф.Имя, GROUP_CONCAT(Объем ||' '|| Цена_руб ||' '|| Код), Описание, Состав, Ф.В_наличие, Расширение, Путь_к_файлу
FROM Товар Т JOIN Фото Ф ON Т.Товар = Ф.Имя JOIN Атрибут_товара А ON Т.Код_атрибута = А.Код GROUP BY Ф.Имя LIMIT 1 OFFSET {i+1}''')
show_infoTovars()
for i in range(2, 6): #Создала список чисел (для rowid)
if text == 'Далее':
#LIMIT 1 OFFSET 2 - получить 1 строку, начиная со 2 записи
#Определим общее кол-во записей выбранной категории
connect_cursor.execute(f'''SELECT Ф.Имя, GROUP_CONCAT(Объем ||' '|| Цена_руб ||' '|| Код), Описание, Состав, Ф.В_наличие, Расширение, Путь_к_файлу
FROM Товар Т JOIN Фото Ф ON Т.Товар = Ф.Имя JOIN Атрибут_товара А ON Т.Код_атрибута = А.Код GROUP BY Ф.Имя LIMIT 1 OFFSET {i+1}''')
show_infoTovars()
Answer the question
In order to leave comments, you need to log in
This "Next" is apparently taken from the bot's keyboard? Those. this is the result of the callback. You can pass the id of the next element "Next_3" to the callback_data and use it when parsing the callback (either as a list index, or rowid, or similar, depending on your logic).
Another option is to store a dictionary with menu states for each user (chat.id). Accordingly, it will be possible to look at the current state in the dictionary and after each "Next" update the next one. Let's put it this way:
Still, this way of pulling records, through sequential limit 1 offset X polls, does not guarantee consistent results without explicit sorting (order by).
menu_info[message.chat.id]['next_id']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question