<div dir="ltr">You just need to generate a quasi-unique number from a set of variables.<br><br>$ php -a<br>php > $string = "Something or other with date and time";<br>php > $hash = md5($string);<br>php > print $hash;<br>
6d1740d6c0c59422b052916acb8ad778<br><br clear="all">Stuff what you want in $string, be it the store, date, whatever.<br><br>Then you can use the $hash value as the key in the database to track<br>this coupon.<br><br>All this would have worked if you have not said it should be short.<br>
<br>But you want it to be short, so the above may be too long.<br><br>Would this work? It is based on the microsecond time. If you<br>have a transaction every few seconds, then it should be OK.<br>Clashes can happen if you have two at the same exact micro-<br>
second.<br><br>$ php -a<br>php > print uniqid();<br>4d20c753e4001<br><br>Short enough?<br><br>Another approach: why not use an autoincrement key in the database table <br>that is the primary key for the coupon table, and be done with it? The<br>
rest of the data can be cross indexed in that table (store ID, date,<br>time, description, ...etc.). It will be just a number.<br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com">2bits.com</a>, Inc.<br><a href="http://2bits.com">http://2bits.com</a><br>
Drupal optimization, development, customization and consulting.<br>Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. -- Leonardo da Vinci<br>
</div>