I’m using MySQL PHP class to get the max id from the table.
$sql="SELECT MAX(id) FROM `".TABLE_CUSTOMERS."`";
$rows = $db->fetch_array($sql);
Now I want to use that max id as value and add 1 to it.
$maxid=rows[0];
$newid=maxid+1;
Above code don’t work.
if I do print_r on $maxid I get that:
( [MAX(id)] => 5 )
Before that MySQL PHP Class I used to do this like that:
$MaxID = mysql_query("SELECT MAX(face_id) FROM `".$DBprefix."faces`");
$MaxID = mysql_fetch_array($MaxID, MYSQL_BOTH);
$MaxID = $MaxID[0];
$newid=$MaxID+1;
And that worked without problem
Here is fetch_array function:
public function fetch_array($sql){
$query_id = $this->query($sql);
$out = array();
while ($row = $this->fetch($query_id)){
$out[] = $row;
}
$this->free_result($query_id);
return $out;
}
try using an alias to define the max value;
and you should be able to retrieve the max value in:
So adding 1: