[Solved] mysql rows count by where clause
Try using this query – $query = mysqli_query(“SELECT subcommentid,COUNT(*) as count FROM table GROUP BY subcommentid ORDER BY count DESC;”); $result = mysqli_fetch_array($query); echo $result[‘subcommentid’].'<br/>’; //subcomment id echo $result[‘count’]; // number of rows If you want all, store in array – $results = array(); while($row = mysqli_fetch_array($query)) { $results[$row[‘subcommentid’]] = $row[‘count’]; } echo “<pre>”;print_r($results);exit; 2 … Read more