PHP/MySQL Can't print column generated by query -
i'm trying build "top 15" results based on field called uid, works great except not printing count column in php, in phpmyadmin though.
select * , count( uid ) count userreports group `uid` order count desc limit 15
here's returning array:
( [id] => 18 [date] => 2016-05-28 13:58:05 [name] => [uid] => [reason] => [staff] => patrick [count] => 2 ) ( [id] => 19 [date] => 2016-05-28 13:58:07 [name] => b [uid] => b [reason] => b [staff] => patrick [count] => 1 )
php code:
if($result) { while($row = mysqli_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['uid'] . "</td>"; echo "<td>" . $row['count'] . "</td>"; echo "</tr>"; print_r($row); echo "<br>"; }
but output doesn't show count column me , can't quite work out why.
thanks in advance.
comment answer, seeing real problem.
you have 6 columns in screenshot, 5 <td>
's in loop. @ own screenshot; have 2 , 1 counts in there. @ html source also; "tool".
what's happening here iterated values have been shifted.
you need match them.
Comments
Post a Comment