Predict the next Bank ID

0

 if (is_uploaded_file($_FILES["foto"]["tmp_name"])) {
$imagem = time() . '_' . $_FILES["foto"]["name"];
$diretorio = 'fotos/ {{{AQUI VIRIA O NUMERO DO ID }}}' . $imagem;
if (!move_uploaded_file($_FILES["foto"]["tmp_name"], $diretorio)) {
  $error = TRUE;
}

I'm using pdo for connection

    
asked by anonymous 01.10.2015 / 22:51

1 answer

1

If your id is with auto_increment simply fetch the information from the table with sql below:

SHOW TABLE STATUS LIKE 'nome_tabela'

Get the value of column Auto_increment

If you are not with auto_increment and you are entering the id manually, just search for the highest id or last registered respectively:

SELECT MAX(id)+1 AS id FROM nome_tabela

and

SELECT id+1 AS id  FROM nome_tabela ORDER BY id DESC LIMIT 1

Just implement it in your code any way you like.

Hope it helps, hugs!

    
01.10.2015 / 23:03