Ask about php summary 01 + 01 = 02
I want to create an id in a database
id_user => data type 'varchar'
I want my id started with 00
, 01
, 02
etc. And to create a new id, I count all rows and the result from count will be added 01.
Example:
$id=array(00,01,02);
$count_exist_id = $count($id)
$new_id= '00' + $count_exist_id
and i hope the new id should be '03'
and it will store the database in the user column of the tableid_user
source to share
You can use INT(x) ZEROFILL
to add 0 before the number. '1' => '001'
With INT ZEROFILL you have AUTO_INCREMENT
.;)
CREATE TABLE user (
id_user INT(8) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id_user)
);
If you use UNSIGNED
, you optimize your table and keep one BIT to get more.
See:
source to share