I used this function to increment a MySQL integer value in a table, the function returns the maximum value to me and adds a number, and then increase the value, because it only works when I add the first record and the next not? If I add the first record (example 11) is fine, if I add another I always 11.
$queryMax=mysql_query("SELECT MAX(NUMERO+1) FROM schederivenditori WHERE IDUTENTE = $id_user");
$row = mysql_fetch_row($queryMax);
$numScheda = $row;
$col["editoptions"] = array("value"=$numScheda);
One thing that looks to be an issue is the sql
Perhaps, It should be MAX(NUMERO)+1 not MAX(NUMERO+1)
$queryMax=mysql_query("SELECT MAX(NUMERO)+1 FROM schederivenditori WHERE IDUTENTE = $id_user");
Also, can you confirm if the correct data is set as default or not. If it is not, you can confirm running query in phpmyadmin or similar that if it is return desited maxid+1.
Let me know the result.
The function of Mysql is correct even so, I use often, I did the test as you said but nothing changes. If I try directly from the MySQL server with Sequel Pro and the query works fine in both cases, there is always the problem when I insert the next record.
Is you case resolved? If not, we can setup a remote desktop session.
Let me know soon.
How useful was this discussion?
Click on a star to rate it!
Average rating / 5. Vote count:
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!