determining the value of an auto-incremented field (mysql)

From: Date: Thu, 16 Aug 2001 17:17:56 +0000
Subject: determining the value of an auto-incremented field (mysql)
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11447@lists.php.net to get a copy of this message
Greetings: A no doubt elementary question, but .... using PHP and MySQL, I'm inserting a record into a table, with a field, order_number, being auto incremented ... something like: $sql = "INSERT INTO orders set products_ordered='$products', ordered_by='$username', company='$company', address_1='$address_1', address_2='$address_2', city='$city', state='$state', zip='$zip', attn='$attn', special_instructions='$special_instructions', shipping_instructions='$shipping_instructions', status='$status', rush='$rush', date_ordered='$current_time' , month_due='$month_due', day_due='$day_due' " ; $result = mysql_query($sql) or die("ERROR -- try again"); Having done so, how can I immediately determine the value of order_number for this entry, i.e. the auto-incremented value assigned by MySQL? Thanks in advance for the help. Kenn Murrah

« previous php.db (#11447) next »