|
Posted by Rhonda on 09/17/05 05:22
"Joel Shepherd" <joelshep@ix.netcom.com> wrote in message
news:joelshep-ADB6F2.19074716092005@news1.east.earthlink.net...
> In article <AZIWe.9281$Ma.2042@fe07.lga>,
> "Rhonda" <nomailplease@yahoo.com> wrote:
> > >
> > > I'm looking at various simple PHP counter scripts, that can double for
my
> > > unique order number.
> > >
> > I solved my problem!
> >
> > How's this look? It works perfect. try it.
> > -----------------------------------------------
> > <html> <!-- O R D E R N U M B E R G E N E R A T O R -->
> > <head>
> > <title>Order Number generator</title> </head>
> >
> > <body onload="GenerateOrderNumber(); document.ordnum.ordernumber.value =
> > GenerateOrderNumber();
>
> [snip]
> >
> > <SCRIPT language="javascript">
> > function GenerateOrderNumber()
> > { tmToday = new Date();
> > return tmToday.getTime(); }
>
> Rhonda, I don't mean to discourage you, but it's important to recognize
> two short-comings of this approach:
> 1) Visitors who don't have JavaScript may not be able to place orders.
> 2) Sooner or later (but certainly sooner than expected) two visitors
> will load the page at the same time (according to Date()), and you will
> receive more than one order with the same order number.
>
> Now, you may not be concerned about lost orders due to #1, and you may
> figure you can use other information (names, addresses, etc.) to deal
> with #2: in that case, go well.
>
> However, if you are concerned about either of those problems (or when
> the day comes that the pain from either is too much), then you'd be much
> better served by using a transactional database to generate sequential
> numbers. Your customers wouldn't need to support any special
> functionality to place orders, and transactions would guarantee that you
> would not generate two identical numbers (or nearly so: there are
> certain edge cases).
>
> You might also consider transforming the sequence number somehow, so
> that folks can't tell whether you've taken 2 orders in the last month or
> 2000, just by looking at the order number. Again, you might not care,
> but in some cases it's important.
>
> Have fun. Order numbers are less trivial than they appear, especially if
> you need a lot of 'em.
>
> --
> Joel.
I know of that shortcoming, but it will suffice until I learn enough about
MySQL to take that step.
Thanks
[Back to original message]
|