Tag Archives: mysql_insert_id

Adding leading zero’s and id’s with php

For a project of mine I had to make a dynamic filename
We decided that the name should always be seven digits long and the file would be correspondent  to the line number in the database. For example line seven would link to a file 0000007.txt.

code for the id from MySQL
$mynr = mysql_insert_id();

code for the seven digits
$mynr = sprintf(“%07d”,$mynr);

Related Blogs

  • Related Blogs on