Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Thanked 0 Times in 0 Posts

    Need advise on how to handle this

    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

  2. #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    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() function.

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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts