I don't post here a lot, just look around mostly, but I need some help with something. I am pulling the max value of a table where the year is equal to whatever year I pass to it. Now, when formatting the number for the user to see, I'd like to add some 0s on the front.
Example: If the number is 37, add a 0 to the front to look like "037"
for a number like 2 it'd be "002"
for a 3 digit number i'd be just whatever the number is. Like 137 would just be "137"
This is my code, but it's not outputting the 0's in the front. The data is pulled from an "INT" column in mysql.
Code: Select all
$tempnum = $row['MAX(rep_autonumber)'];
if($tempnum < 10)
{
$newnum = "00".$tempnum + 1;
} else if($tempnum < 100) {
$newnum = "0".$tempnum + 1;
} else {
$newnum = $tempnum + 1;
}Thanks,
Dan