Auto Increment PHP giving error

-9

In this code below, I created a auto increment in php, but it is giving an error in the sum. Example: It works perfectly 1,2,3 ... 10, up to number 10. From there it repeats the 10, 10, 10

$qr = mysql_query("SELECT max(os) as os FROM a_finan where   
id_transfer='$id_transfer'");  // pega o ultimo numero da coluna
$z = mysql_fetch_object($qr);
$cod1 = $z->os;

if($cod1 == 0){  // Se numero for 0  o primeiro registro vai ser '1' 
$os= 1;
}else{           
$os = $cod1 + 1; // se não conte o ultimo numero e some +1   
}

How are you?

   1,2,3,4,5,6,7,8,9,10,10,10,10,10...

As it should be

1,2,3,4,5,6,7,8,9,10,11,12,13,14...

What should I be doing wrong?

    
asked by anonymous 23.06.2015 / 19:23

1 answer

-10

I changed the field from VARCHAR to INT and funcinou .

    
23.06.2015 / 20:14