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.

missing column

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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -