Posted By

llbbl on 05/27/07


Tagged

mysql php textmate increment lastid


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Auto Increment Function


 / Published in: HTML
 

  1. function mysql_autoid($id,$table){
  2. $query = 'SELECT MAX('.$id.') AS last_id FROM '.$table;
  3. $result = mysql_query($query);
  4. $result = mysql_fetch_array($result);
  5. return $result[last_id]+1;
  6. }
  7.  
  8. // usage mysql_autoid('nID','news');
  9. // for use with fields that don't have auto_increment enabled
  10. // otherwise just use $last_id = mysql_insert_id(); following a successful INSERT
  11.  

Report this snippet  

You need to login to post a comment.