I have the following code:
JavaScript
x
$query3 = "SELECT
Office,
COUNT(Office) As Tot_Part,
(SELECT COUNT(Office) FROM trespondent WHERE completion_status= 'Started' OR completion_status = 'Complete') As Total_Resp
FROM trespondent
WHERE completion_status <> 'New'
GROUP BY Office
ORDER BY Office";
$result3 = $mysqli->query($query3);
I am trying to move from mysql
to mysqli
and am struggling terribly. The above statement brings back only 1
row and not the 26
that there should be. Any pointers welcome.
Advertisement
Answer
That’s because you’re fetching just one row ($los = $result3->fetch_row();
).
Try it in a loop.
Like this:
JavaScript
$result3 = $mysqli->query($query3);
while($los = $result3->fetch_row()) {
print_r($los); /* sanity */
}