Hello, I wanted to assign fixed letters to a column in mysql and generate a consecutive number, this number has already been generated with the following code:
<?php
$consulta = mysqli_query($mysql,'SELECT MAX(num) as num FROM num_ficha LIMIT 1');
$consulta = mysqli_fetch_array($consulta,MYSQLI_ASSOC);
// Si el codigo actual esta vacio o es 0, se convierte en 1.
// En caso contrario se le suma +1.
$codigo = (empty($consulta['num']) ? 1 : $consulta['num']+=1);
echo 'El codigo actual es: '.$codigo;
$consulta = mysqli_query($mysql,'INSERT INTO num_ficha (num) VALUES ('.$codigo.')');
if(!$consulta){die('Error');}
?>