Help! Run Product Order Number Start with Alphabet

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
prasitc2005
Forum Commoner
Posts: 42
Joined: Thu Jul 13, 2006 7:14 am

Help! Run Product Order Number Start with Alphabet

Post by prasitc2005 »

Hi All Gurus

Please help me. I would like to do automatic order number which will run from W1000 then it will become W1001, W1002...

I have tried many ways but couldn't insert it into my email order form yet. This is my mess:

Code: Select all

$firstset = 'W1000';
for($i=1;$i<8;++$i) {
$orderid = $firstset+$i;
{
Please suggest some solutions! Thanks!
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Ignore the letter W to start with. Generate your number first. Then prefix the number with W
User avatar
prasitc2005
Forum Commoner
Posts: 42
Joined: Thu Jul 13, 2006 7:14 am

Thank Jay

Post by prasitc2005 »

Thank Jay! Could you pls give an example of code. Thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

How do you keep a track of the order numbers you have already used?
User avatar
prasitc2005
Forum Commoner
Posts: 42
Joined: Thu Jul 13, 2006 7:14 am

Post by prasitc2005 »

Thanks! I have tried to input the result into mysql database but it doesn't go through as there's no form for these.

However, I really need to know first how to generate order number beginning with W1001, W1002 etc. Thanks!
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

If you setup your database first you can query the database for an descending list of order numbers,
limit them to the top result, do the simple $i++ and make it unique.
Post Reply