Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-02-2006, 05:05 PM   PM User | #1
mwm
Regular Coder

 
Join Date: Oct 2005
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
mwm has a little shameless behaviour in the past
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
mwm is offline   Reply With Quote
Old 11-03-2006, 06:38 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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()); 
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:26 AM.


Advertisement
Log in to turn off these ads.