如何在jquery中创建一个唯一的id? [英] how to create a unique id in jquery?

查看:146
本文介绍了如何在jquery中创建一个唯一的id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成c_123,c_124等形式的唯一客户ID ..





这个值应该是单击按钮时插入文本框..

id值应使用phpmysql存储在数据库中。







表名为'self_ticket_rising',库存名称为'cust_id'



button id ='click'

textbox id ='cust_ids'

i need to generate a unique customer id of the form c_123,c_124 and so on..


this value should be inserted in a textbox on clicking a button..
the id value should be stored in database using phpmysql to.



the table name is 'self_ticket_rising' and coulmn name is 'cust_id'

button id='click'
textbox id='cust_ids'

推荐答案

将自动增量主键(例如id)添加到表中,然后将customer_id列创建为生成列 [ ^ ]其值来自 concatenat [ ^ ]带有主键值的'c_'。

+++++++++++++++++++++++++++++++++++++++++ $ b好的,试试这个。

1.创建一个新表,比如'dummy',只有一个名为id的自动增量主键列。

2.每次需要新的客户ID单击一个按钮后,向此表插入一个空值,如下所示:

Add an auto-increment primary key, say id, to the table, then create the customer_id column as a Generated Column[^] the value of which derives from concatenating[^] the 'c_' with the primary key value.
++++++++++++++++++
Ok, try this.
1. Create a new table, say 'dummy', with only one auto-increment primary key column called id.
2. Every time you need a new customer id upon clicking a button, insert a null value to this table like this:
insert into dummy set id=null






or

insert into dummy values (null)



3.步骤2将生成一个新的唯一ID,检索这个id使用 PHP mysqli_insert_id()函数 [ ^ ]并将其与其他前缀连接起来,比如'c_',以获得唯一的客户ID。

通过这种方式,您可以确定没有两个用户获得相同的客户ID。


3. step 2 will generate a new unique id, retrieve this id using PHP mysqli_insert_id() Function[^] and concatenate it with other prefix, say 'c_', to get a unique customer id.
In this way, you are certain that no two users get the same customer id.


这篇关于如何在jquery中创建一个唯一的id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆