...

View Full Version : Need advise on how to handle this



mwm
11-02-2006, 06:05 PM
I'm writing a work order system that has users enter customer info for service. I have to main mysql tables. 1) customers and 2) csi which is the table that stores the work order. What I need is to have the work order form filled out then update the db and present the user the data back to give them a choice to print it. all works well except for the following.

when presenting the user the updated form no info is being displayed because the work order ($woid) is not available until the order is created. When the work is first being created woid doesn' t have any value until the time it is sent to the db to be entered into the table it is auto inc. What can I do, any suguestion.

Thank You

Fumigator
11-03-2006, 07:38 AM
I think that was the really really long way to ask how you can determine what the value of an auto-increment key is after an insert.

Use the mysql_insert_id() (http://us2.php.net/manual/en/function.mysql-insert-id.php) function.



mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum