Please tell me why it gives me always zero value?

$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' ";


global $total;

$total = $total+mysql_num_rows($res);
                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.

Recommended Answers

All 2 Replies

Member Avatar

That looks like a very convoluted piece of code. I'm sure there's an easier way of doing what you want. Could you please write out in steps (1. ... 2. ... etc), what you're trying to achieve.

I got the problem, i didn't call the function.

Be a part of the DaniWeb community

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