dongzaotiao2863 2014-10-08 09:19
浏览 12

检索数据库中的下一个id,这可能不是下一个自动递增的数字php mysql

apologies as this seems to me to be a very simple answer, but am struggling to find a solution having searched around.

I have a pretty simplistic table that stores a series of info for booking a caravan - options are one week or two week bookings. I've previously used (and successfully for the last however many years) a simple if else statement to check availability. The weeks are sequential in the database on an auto incremented basis and i simply searched for the next week and a third week as a fail safe by

$next_week_id1 = $row['id'] + 1; and $next_week_id2 = $row['id'] + 2;.

Basic I know, but it has worked until now where there has been some kind of discrepancy with the auto increment - I have an id which misses the next incremental value so from id 91 for example it goes to 93, which messes up the whole script.

Its been a while since I touched this, just wondering how you'd hit the next value in the database (for the second week and then the third week) without using the id as an incremental stepping stone? They will always be the next one in the list, but clearly using id+1 or id+2 is a non-reliable way of accessing this...

Thanks for any advice.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 vue3加ant-design-vue无法渲染出页面
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决
    • ¥15 processing提取音乐节奏
    • ¥15 gg加速器加速游戏时,提示不是x86架构
    • ¥15 python按要求编写程序