note 83942 added to function.mysql-insert-id

From: Date: Thu, 19 Jun 2008 20:13:47 +0000
Subject: note 83942 added to function.mysql-insert-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-140595@lists.php.net to get a copy of this message
Other methods seem to have problems with missing records in auto increment sometimes you will have records 1 2 5 6 most functions would return the value of 5 for next auto increment when indeed it would be 7. This is the only way I found to make this work so I can use my customer number and the record number to provide a truly unique customer number that is also useful. $next_increment = 0; $qShowStatus = "SHOW TABLE STATUS LIKE 'your_table'"; $qShowStatusResult = mysql_query($qShowStatus) or die(mysql_error()); $row = mysql_fetch_assoc($qShowStatusResult); $next_increment = $row['Auto_increment']; echo $next_increment; then you can do something like this echo $next_increment ."-". rand(); My first post: I hope this is useful to someone ---- Server IP: 64.71.164.2 Probable Submitter: 208.54.14.17 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php Edit -- https://master.php.net/note/edit/83942 Del: integrated -- https://master.php.net/note/delete/83942/integrated Del: useless -- https://master.php.net/note/delete/83942/useless Del: bad code -- https://master.php.net/note/delete/83942/bad+code Del: spam -- https://master.php.net/note/delete/83942/spam Del: non-english -- https://master.php.net/note/delete/83942/non-english Del: in docs -- https://master.php.net/note/delete/83942/in+docs Del: other reasons-- https://master.php.net/note/delete/83942 Reject -- https://master.php.net/note/reject/83942 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140595) next »