0

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.

Edited by dushtu.bor: n/a

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by dushtu.bor
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.