0
Insert record in php and MySQL and generate id based on that.
I want to insert a record in php and then generate an ID based on that. for instance if I insert "shyam" as name and my id is 1 in the table which is primary key. once my record is inserted an Id should be generated like shy001. if name is Vikas and id is 2 then id should be vik002.
1 ответ
0
$zeros = "";
if (mysql_insert_id () <10) {
$zeros = "00";
} else if (mysql_insert_id () <100) {
$zeros = "0";
}
$id = $substr($var,1,3).$zeros.mysql_insert_id ();