简体   繁体   English

在php上删除数据后无法创建新记录

[英]can't make a new record after delete data on php

im newbie here, i have a trouble like this. 我是新手,我有这样的麻烦。

table: nota 表:nota

no_nota(pk) name addres no_nota(pk)名称地址

D01 xxx xxxx D01 xxx xxxx

D02 xxx xxxx D02 xxx xxxx

D03 xxx xxxx D03 xxx xxxx

when im delete no_nota "D02" then i want to make new record, no_nota should be D04. 当我删除no_nota“ D02”时,我想做新记录,no_nota应该是D04。 but in my case no_nota be D03 not D04. 但在我的情况下,no_nota是D03,而不是D04。 my syntax code like this. 我的语法代码是这样的。

<td>No Nota : </td> <td><?php $sql=mysql_query("SELECT * FROM nota"); $data=(mysql_num_rows($sql)+1); ?> <input type="text" value="<?php echo "$data"; ?>" name="no_nota" required/><b></b> </td>

someone how can tell me the right syntax? 有人怎么能告诉我正确的语法? sory for my bad english regards, 抱歉我的英语不好,

It seems you don't need to store your no_nota at all. 看来您根本不需要存储no_nota Using an auto-increment from the database, you will always have the correct number and you can build your no_nota on the fly. 使用数据库中的自动增量 ,您将始终拥有正确的数字,并且可以动态构建no_nota

After inserting in the database of course. 当然插入数据库之后。 Technically you could query for the next auto-increment number but that will get you into a race condition if multiple users are using the system at the same time. 从技术上讲,您可以查询下一个自动递增编号,但是如果多个用户同时使用系统,这将使您陷入竞争状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM