How would i go about counting the number of rows that match two variables?
I have a table called: users
and fields called: username & referral
I have another table called: comments
and fields called: *comment_username*
This is the situation, I need to fetch the number of referrals with at least 10 comments (rows in the comments' table) that a specific user has referred.
So i was thinking the code should be something like this crude outline.
$username = 'bob';
$validrefferalcount = 0;
function validreferrals($username){
$referreduser = SQL select * from users where referral='$username';
foreach ($referreduser) {
$numberofcomments = SQL count * from comments where comment_username ='$referreduser';
if ($numberofcomments >= 10){
$validreferralcount = $validreferralcount + 1;
}
}
return $validreferralcount;
}
I apologize for the bad syntax, etc...
Thanks for reading.