look at the database here ---->http://www.tiikoni.com/tis/view/?id=908d940
in the subcommentid rows, value 63 is repeating maximum time itself 7 times
i want to fetch this value in numerical form means like this
maximum rows in subcommentid is 7
i hv tried this
$query=mysqli_query("SELECT * FROM table WHERE where id='63'");
echo mysqli_num_rows($query);
but
but 63 is a variable so how can a server pre decide that 63 is repeating itself maximum nos
nd look at dix ques too cant get my desire result of max(like)
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;
use select count(*) from.....
Or
use mysql function mysql_num_rows($query_result).
$query = "SELECT * FROM comments WHERE id=`7`";
$result = mysqli_query($sql, $query);
$rows = mysqli_num_rows($result);
Use mysqli_num_rows
function in php to count the no.of rows. Your code should look like this
$query=mysqli_query("SELECT * FROM table WHERE where id='63'");
echo mysqli_num_rows($query); // will echo no.of rows having id 63
Hope this helps you