bri0987 Posted November 27, 2007 Share Posted November 27, 2007 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 Quote Link to comment Share on other sites More sharing options...
revraz Posted November 27, 2007 Share Posted November 27, 2007 Why not just make the invoice_num the order_id? Do you have a requirement that you need two seperate numbers? Or, read the DB, get the last invoice_num used, increment it, and use it. Quote Link to comment Share on other sites More sharing options...
bri0987 Posted November 28, 2007 Author Share Posted November 28, 2007 How do I start the ORDER_ID at "100000" so that the first ORDER_ID will come out at "100001" Thanks, BRI Quote Link to comment Share on other sites More sharing options...
Eiolon Posted November 28, 2007 Share Posted November 28, 2007 Take a look here for changing the auto_increment: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_auto-increment-increment Quote Link to comment Share on other sites More sharing options...
revraz Posted November 28, 2007 Share Posted November 28, 2007 I created a new Table, set the first record to 10000 and auto increment, i inserted a 2nd row and it went to 10001. So just set the first record. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 28, 2007 Share Posted November 28, 2007 in phpmyadmin you can adjust the start count on it so it starts at 10000, but technically you could just pad it to be "6" digits" Quote Link to comment Share on other sites More sharing options...
bri0987 Posted November 28, 2007 Author Share Posted November 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
bri0987 Posted November 28, 2007 Author Share Posted November 28, 2007 TOPIC CONTINUED AT: http://www.phpfreaks.com/forums/index.php/topic,169563.0.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.