Forum Moderators: coopster

Message Too Old, No Replies

PHP MYSQL DATABASE for RMA system

RMA System

         

callmeberadical

7:06 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



i have the database set up and the php code i just dont know how to make mysql generate a unique RMA id number for each entry and then echo it back to the customer so they can send there defective product back to us and i can look up their info via the RMA id number form the database... Anythoughts would be greatly appreciated.

ergophobe

7:58 pm on Aug 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What do you have so far? Assuming that you have a DB table that holds RMAs and that table has a primary key, that would do just fine. Since that key is probably an auto-incrementing field, you need to submit (i.e. INSERT) the data first, and then find out what the key is and send it to the user. You find by one of two methods.

Best is to run something like this query:

SELECT LAST_INSERT_ID() as rma_id

See the mysql manual:

[dev.mysql.com...]

[dev.mysql.com...]

callmeberadical

8:59 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



Yes i have the db setup with an auto increment field as primary. So after the form has inserted the data to the db use the SELECT LAST_INSERT_ID() as rma_id command. Now how do i get the auto increment field to increment say a number like 9999* . * = the auto increment number starting at 1. Is that possible?

I am new to php and mysql and but i am a fast learner i just need some help finding out this info and how to echo that auto incremented number back to the customer via a web page and email.

thanks,
brad

ergophobe

9:38 pm on Aug 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So you want your numbers to all start with 9999 so that the series would look like

99991
99992
99993
....
999978391
999978392

et cetera?

In that case, all you need to do is create a record numbered 99990

INSERT INTO table1 (rma_id, rma_description, customer_name) VALUES ('99990', 'placeholder', 'admin');

DELETE FROM table1 WHERE rma_admin=99990

Now the first record in your table will be 99991

Is that what you're asking?

Tom

callmeberadical

4:29 pm on Aug 18, 2004 (gmt 0)

10+ Year Member



yeah thanks man i really appreciate your help alot!