ivytony Posted February 17, 2008 Share Posted February 17, 2008 After a customer places an order on my online eshop, I would like to show him/her the order number (the primary auto-incremented ID in mysql database table 'order') on the confirmation page and send the order number to his/her email automatically. My thinking is to get the last auto-incremented ID and then plus 1 as the order number. Is this right to do? I am wondering how to do this? thanks! Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted February 17, 2008 Share Posted February 17, 2008 I wouldn't do it that way because someone else may place an order that gets written to the database before the first person completed their order. I would write it to the database, then grab the id to display the order number to the user. Quote Link to comment Share on other sites More sharing options...
ivytony Posted February 17, 2008 Author Share Posted February 17, 2008 I found php has a function called mysql_insert_id, which can retrieve the latest auto increment id from last insert. Is this good? thanks! Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 17, 2008 Share Posted February 17, 2008 I found php has a function called mysql_insert_id, which can retrieve the latest auto increment id from last insert. Is this good? Yes, that is the correct function to use in this case 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.