我想自动增加字母数字字符例如:amp001,amp002,amp003 谁能帮我解决这个问题。
我应该得到像
id
abc001
abc002
abc003
abc004
..
..
..
我想自动增加字母数字字符例如:amp001,amp002,amp003 谁能帮我解决这个问题。
我应该得到像
id
abc001
abc002
abc003
abc004
..
..
..
You can't auto increment alphanumeric values. Just Change the field type to numeric and set auto increment to that field. Concate your string value before the ID, while fetching the value. Eg: <?php echo "abc".$row['id']; ?>
If you really want this, use php's uniqid function.
看这个例子
//connect to you database
//$count = mysql_query("select count(*) from table_name");
$id = "abc";
if (strlen($count+1) < 4)
{
$count++;
for($i=0;$i<(3 - strlen($count));$i++)
{
$id .='0';
}
$id .= $count;
}