Thanks for your help John that works really well :)

Cheers
Peter

-----Original Message-----
From: John Holmes [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 30 May 2002 12:08 PM
To: 'Peter'; 'Php'
Subject: RE: [PHP] generating next number... from db extraction


Okay...here's the "what they don't know won't hurt them solution":

CREATE TABLE (ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Cnt CHAR(2),
Quote TEXT) AUTO_INCREMENT = 20120250;

Adjust your table accordingly, but the idea is that this auto_increment
column will now start counting at 20120250 and go up from there. So you
can get away with starting at a 7 or 8 digit number and make the quote
IDs look like they want. Use the 'Cnt' column as the "update" column.
Start it out with empty string as default. On first revision set it to
'A', etc. If you select out this column, you can use PHP to "add" a
letter. i.e. 

for($x='a';$x<='z';$x++)
{ echo $x; }

That'll print the letters of the alphabet. Use the same concept to add
one to 'A' and get 'B'. 

So the client will be happy b/c it looks like they want and you'll be
happy b/c you're using an auto_increment column. 

---John Holmes...

> -----Original Message-----
> From: Peter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 29, 2002 9:38 PM
> To: Php
> Subject: RE: [PHP] generating next number... from db extraction
> 
> unfortunately  they want letters in it ... I know it would be easier
to
> hav
> auto_incroment.. and wish I could just leave it at that ..
> 
> for the bulk of it i could get away with having no letters but they
have
> requested to have the letter in the update part .... eg 12345 becomes
> 12345-A after the update ...
> 
> -----Original Message-----
> From: John Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 30 May 2002 11:22 AM
> To: 'Peter'; 'Php'
> Subject: RE: [PHP] generating next number... from db extraction
> 
> 
> Why does it have to be letters and numbers? You're just making more
> work. You can use an auto_increment field and not worry about it
> (assuming MySQL).
> 
> You can also use uniqid() and md5() to make a unique string, but it'll
> be 32 characters long. Maybe crypt() is 16 characters...dunno, but you
> could try that.
> 
> www.php.net/uniqid
> 
> ---John Holmes...
> 
> > -----Original Message-----
> > From: Peter [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, May 29, 2002 8:28 PM
> > To: Php
> > Subject: [PHP] generating next number... from db extraction
> >
> > hi,
> >
> > I'm making a quoting system and need to have letters & Numbers
inside
> the
> > quote number. Now if I was to grab the last quote number inserted
into
> the
> > db and then do something like
> >
> > //example of $quoteID value w/out letters
> > $quoteID = 20120250;
> > //example of  $quoteID with letters
> > //$quoteID = abc20250;
> >
> > $quoteNUM = $quoteID  + 1;
> > echo $quoteNUM;
> >
> > it will work fine .. but the minute i add a letter to this is
> doesn't...
> > now
> > I know I can generate random numbers and letters  but I need to have
> some
> > order about it so the quote numbers are not all over the place...
Also
> as
> > an
> > addition providing I can get this working .. I would also like to
have
> it
> > so
> > that if a quote was updated the quoteID would be changed ... eg:  if
> the
> > quote number was abc20250 after it was updated it would be
abc20250-A
> or
> > something along those lines ...
> >
> >
> >
> > Cheers
> >
> > Peter
> > "the only dumb question is the one that wasn't asked"
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to