Forum Moderators: coopster
Say when I get up to a 100 would the 000 turn 00 then.
Would it be some thing like this
$string = '100';
$length = strlen ($string);
if ($length = 3) {
echo '000'.$string;
} elseif($length = 3){
echo '000'.$string;
}
[edited by: fintan at 8:04 pm (utc) on Jan. 12, 2005]
also look at
[dev.mysql.com...]
and look at the ZEROFILL attribute, sorry, forgot to mention this last time. Then you don't have to do anything with PHP. ;)
mysql> CREATE TABLE `appldetails` (
-> `applid` mediumint(8) zerofill PRIMARY KEY auto_increment);
mysql> describe appldetails;
+--------+--------------------------------+------+-----+---------+----------------+
¦ Field ¦ Type ¦ Null ¦ Key ¦ Default ¦ Extra ¦
+--------+--------------------------------+------+-----+---------+----------------+
¦ applid ¦ mediumint(8) unsigned zerofill ¦ ¦ PRI ¦ NULL ¦ auto_increment ¦
+--------+--------------------------------+------+-----+---------+----------------+
and then did
mysql> insert into appldetails values ('');
Query OK, 1 row affected (0.02 sec)
mysql> select * from appldetails;
+----------+
¦ applid ¦
+----------+
¦ 00000001 ¦
+----------+
1 row in set (0.00 sec)
so it worked for me