I want to make a id in database
id_user => data type 'varchar'
I want my id to start from 00, 01, 02, and so on.
And to make new id, I count the all the rows, and the result from count will be added by 01.
Example:
$id=array(00,01,02);
$count_exist_id = $count($id)
$new_id= '00' + $count_exist_id
and I hope the new id must be '03' and it will be store to database in table user column id_user
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 you save one BIT, to get bigger number.
See :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With