PHP 5.x mysqli - interactive query


Whatever is given in the SELECT statement to mysqli_query is going to return a mysql_result type if the query was successful. So if you have a SELECT statement such as:
SELECT sum(field) FROM table1
you still need to fetch the row with the result, and the value of the sum() function will be the only entry in the row array:
$res = mysqli_query($dbh,'SELECT sum(field) FROM table1');
if (FALSE === $res) die("Select sum failed: ".mysqli_error);
$row = mysqli_fetch_row($res);
$sum = $row[0];

留言

這個網誌中的熱門文章

tw quote

三重幫 - 2013-09-11

FPDF Big5 Font