Jump to content

Finding out current auto_increment number?


Mutley

Recommended Posts

I have a form that uploads an image, that I want to rename the image to the next auto_increment number that is in a field (id) of a row. How do I do this?

 

I was trying to SELECT the last "id" and add 1 but obviously if I deleted a row, then went to add another picture, it would be 1 behind/incorrect.

I believe you would select all records, and loop through them, making PHP set a variable to the number if that is higher than the currently open variable.  What I mean is:

 

$curr = SQL_QUERY;

if($curr > $x){

$x = $curr;

}

 

I'm not sure if there is another method.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.