php and mysqli object

hello every one,

I’m using php and mysqli extension object to execute a some sort of aggregate SQL function like COUNT(*), Sum(Price), or Avg(Quantity)
i only need to get the single value rather than the whole array result set.

i’m looking for some way to get the value of the first row in the first column from a result set

i was looking at the MySQLi Extension Object reference at PHP: The MySQLi Extension Function Summary - Manual
but i can’t find what i’m looking for …?

It’s no different from fetching multiple rows of multiple columns. There is just one row in the result array and you take the first (and only) column.

Here is my example:

$result = $mysqli->query(“SELECT COUNT(id_event) FROM prenotations WHERE id_event =’”.$id_ev."’");
$row = $result->fetch_row();
$prenotations_num = $row[0];