Please tell me why it gives me always zero value?
<?php
$total =0;
$memid = $_POST['username'];
$leg = $_POST['leg'];
mysql_connect ("host", "usr", "paswd") or die ('Error: ' .mysql_error());
mysql_select_db ("dbname");
function getTotalLeg($memid,$leg){
$sql="select $leg from `users` where `username`='$memid' ";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
global $total;
$total = $total+mysql_num_rows($res);
if($row['$leg']!=''){
getTotalLeg ($row['$leg'],'lname');
getTotalLeg ($row['$lrg'],'rname');
}
return $total;
}
echo $total;
?>
Please, solve it. I want to count how much i have in my left or right, sum of total in binary tree.