下面是我的代码我生成的字母数字字符串,但问题是如何在提交表单后将生成的字符串存储到db phpmyadmin以便唯一地获取列。
我的代码:
function rand_string( $length ) {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return substr(str_shuffle($chars),0,$length);
}
echo "div style='color: black; font-weight: bolder; size: 35px; position: absolute; top: 25px; right: 25px '>APPLICATION ID->".rand_string(6);
答案 0 :(得分:0)
试试这个会起作用:
function rand_string( $length ) {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return substr(str_shuffle($chars),0,$length);
}
$rand_str = rand_string(6);
INSERT INTO table_name
VALUES ($rand_str,$value2,$value3,...);
此处,$rand_str
是随机生成的字符串,可用于唯一标识行。