------------------
1 | abc
2 | def
3 | ghi
4 | jkl
I have a table setup like above..
and I am trying to get the largest 'id' value with max()
Code: Select all
$mysqldb->query("SELECT max(id) FROM TbName");
$id = $mysqldb->fetchObject();
$id = $id->value;functions used for the script:
Code: Select all
function query($query) {
try {
$this->result = @mysql_query($query,$this->linkid);
if (! $this->result)
throw new Exception("The database query failed.");
}
catch (Exception $e) {
echo ($e->getMessage());
}
$this->querycount++;
return $this->result;
}
function fetchObject() {
$row = @mysql_fetch_object($this->result);
return $row;
}