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
prasitc2005
Forum Commoner
Posts: 42 Joined: Thu Jul 13, 2006 7:14 am
Post
by prasitc2005 » Thu May 17, 2007 11:03 am
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!
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 17, 2007 11:06 am
Ignore the letter W to start with. Generate your number first. Then prefix the number with W
prasitc2005
Forum Commoner
Posts: 42 Joined: Thu Jul 13, 2006 7:14 am
Post
by prasitc2005 » Thu May 17, 2007 11:12 am
Thank Jay! Could you pls give an example of code. Thanks
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 17, 2007 11:26 am
How do you keep a track of the order numbers you have already used?
prasitc2005
Forum Commoner
Posts: 42 Joined: Thu Jul 13, 2006 7:14 am
Post
by prasitc2005 » Thu May 17, 2007 11:29 am
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 » Thu May 17, 2007 2:47 pm
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.