简体   繁体   English

PHP / HTML Web应用程序中的全局计数器变量

[英]Global Counter Variable in a PHP/HTML web application

I am coding a web application to practice implementing MySQL databases, so I am not concerned with the "correctness" or "efficiency" of what I'm trying to do. 我正在编写一个Web应用程序以练习实现MySQL数据库,因此我不关心我要执行的操作的“正确性”“效率”


Question: 题:

The primary key for the database with User's information is the Member ID Number , but upon registering the member does not know their ID number as it should be automatically assigned. 具有用户信息的数据库的主键是会员ID号 ,但是在注册时,会员不知道其ID号,因为应该自动分配该ID号。 The user just has to enter their name, address, etc. to register. 用户只需输入其姓名,地址等即可注册。

The way I have it working now is just taking all the information from an input form and using that to add an entry to the MySQL table. 我现在的工作方式是从输入表单中获取所有信息,然后使用该信息将条目添加到MySQL表中。 The issue is that I need the Member ID Number, which I can't get from the user. 问题是我需要会员ID号,而我不能从用户那里得到。

Is it possible to have a global counter variable that increments every time a member is registered? 是否有一个全局计数器变量,该变量在每次注册成员时都会增加? ie the first member is given ID 1, then 2, then 3, etc. 也就是说,第一个成员的ID为1,然后为2,然后为3,依此类推。

If so, how would I implement it? 如果是这样,我将如何实施? I'm comfortable with global variables and such in other programming languages but have never used PHP/HTML before. 我对其他编程语言中的全局变量等很满意,但以前从未使用过PHP / HTML。

Thanks! 谢谢!

如果您使用的是MYSQL,则可以在将ID存储为AUTOINCREMENT的表中设置列,有关如何将列设置为自动增量的更多信息,请参见此处

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

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