Jump to content

[SOLVED] Invoice number with MySQL and Php ... Hmmm.


bri0987

Recommended Posts

Okay here I go:

 

I have a custom built shopping cart. After the customer checks out, I inserting the order information into the MySQL Database.

 

The fields I have are:

 

ORDER_ID >> (auto_increment filed)

Orderstatus_ID (the status)

Invoice_Num (THE PROBLEM!!!!)

Customer_ID (Customer info)

Product_ID (What they ordered)

Component_ID (options for what they ordered)

Order_Date >> (Time stamp)

IP_Address  >> (the customers IP address, just incase of a hack or something, I thought it would be good)

 

I need the invoice number to be at least 6 digits long (at least)

I tried doing auto_increment on the Invoice_Num field but MySQL says only one auto increment field for just one table, and Order ID is already set to use the auto increment

 

I dont care how many digits is in the Invoice number but I wanted to stay away from random numbers just because there is a small chance of getting the same random number.

 

How can I auto increment the Invoice_Num field in this table or use some sneaky php code to get around it:

 

Thanks for reading

 

BRI

Link to comment
Share on other sites

Okay I figured that part out but know I have a new problem.

 

In the THANK YOU PAGE for the customer I have to give them the Order/invoice number.

 

I could get the most recently made ID from the database and display it to them but that would cause some BIG problems if there are a few hundred people on the web site at one time and ordering products.

 

So my question is:

 

How can I get the ID for the information as the same time I insert the data?

 

(I hope I asked that right)

 

Thanks

 

BRI

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.