On Wed, Aug 03, 2005 at 08:57:20PM -0700, operationsengineer1@yahoo.com wrote:
> --- Gordon Haverland <ghaverla@shaw.ca> wrote:
>
> > On Wednesday 03 August 2005 15:23, operationsengineer1@yahoo.com wrote:
> > > can i use pgsql to force th einput of leading zeros?
> > > i have an application that enters serial numbers within a range,
> > > eg, 00001 to 00003.
> > Use a string type, but only allow certain characters.
> Gord,
>
> if i do that, though, i think i'm unable to increment
> the number string in php. the user inputs the
> beginning and ending s/n only. i use php to create
> and enter the other s/ns. can i still increment a
> number string using i++?
You probably could do it as a string in php, but I think I'd use it as a
decimal in php, and then use a printf() statement when you do an insert.
Like this example (where mycol is of some string type):
<?php
$num = 12;
$sql = "INSERT INTO table (mycol), VALUES('" .
printf("%06d",$num) . "')";
?>