You are here: Re: SOLVED!!! Re: Create Sequential number / Text file read-write... « HTML « IT news, forums, messages
Re: SOLVED!!! Re: Create Sequential number / Text file read-write...

Posted by Joel Shepherd on 09/17/05 05:07

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация