Also, when there is no entry in the table, it prints 2, I run the sql query and in the phpmyadmin it shows null. Any idea? Apparently, if there is no entry I expected it to return 0.
I am just trying to find out the highest id no in the table.
Code: Select all
$query= "SELECT max(id) AS total FROM request";
$result = $connector->query($query);
$num = mysql_num_rows($result);
if($num>0) {
while($row=$connector->fetchArray($result)) {
$total = $row['total'];
}
}
echo $total;