i want to get the result of my count query in 2 table
my table :

    $userfans=mysql_query("select *from fans where id_userfans='$_SESSION[id_user]' and level='umum' limit 1");
    while($oinf=mysql_fetch_array($userfans)){
        $coinp=mysql_query("select * from fans_news where id_userf='$_SESSION[id_user]' and id_fans='$oinf[id_fans]' and status='Y'");
        $koinp=mysql_num_rows($coinp);
        while($oinp=mysql_fetch_array($coinp)){

        $comentar=mysql_query("select * from fans_comment,user where fans_comment.id_newsfans='$oinp[id_newsfans]'
        and fans_comment.id_usercf!='$_SESSION[id_user]' and fans_comment.id_usercf=user.id_user ");

    $comme=mysql_num_rows($comentar);   
    echo" ($comme) </br>";   

    }
    }

and the result :
(4)
(2)
(2)
(0)
(1)
(0)
(0)
(1)
(0)
(0)

but i want to calculate that count result. become -->10
anyone can help me
im so confuse..

You can use += which will add onto each previosu total through a loop

$koinp=mysql_num_rows($coinp);
$total = 0; // Put this is to define the variable and set the initial amount to 0
while($oinp=mysql_fetch_array($coinp)){



$comme=mysql_num_rows($comentar);   
   // echo" ($comme) </br>";
$total += $comme; // Add each value of $comme to the current $total

The outside your loop echo the $total

I have the following table:

memberid  
2
2
3
4
3
...and I want the following result:

memberid    count
2           2
3           1    ---Edit by gbn: do you mean 2?
4           1
I was attempting to use:

  SELECT MemberID, 
         COUNT(MemberID) 
    FROM YourTable 
GROUP BY MemberID
...but now I want find which record which has maximum count. IE:
commented: Start your own thread! -2
SELECT MemberID, 
         COUNT(MemberID)  cnt
    FROM YourTable 
GROUP BY MemberID
order by cnt desc 
limit 0,1
commented: Don't answer someone else's question when they have hijacked a thread -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.