Okay so I have a query like this one
$get_downlines = "SELECT * FROM referrals WHERE ref_upline = :rupline";
$get_downlines = $pdo->prepare($get_downlines);
$get_downlines-> bindValue(':rupline', $sessionid);
$get_downlines-> execute();
while($fetch_downlines = $get_downlines->fetch()){
$rdownline = $fetch_downlines['ref_downline'];
$dr = "SELECT * FROM `ads_viewed` WHERE av_user = :user";
$dr = $pdo->prepare($dr);
$dr-> bindValue(':user', $rdownline);
$dr-> execute();
echo $dr_count = $dr->rowCount();
}
The code above gives me the row counts as say 3456
(all are separate counts like 3,4,5,6). Now I want to sum up all these rows here and get the result as 3+4+5+6 = 18
. And assign it to a global variable which can be used anywhere outside while loop (if possible). How can this be done?