I want to get the sponsor level from the given agent id.So i'm using the following code:
function categoryChild($agent,$property) {
global $sponser;
$s = "SELECT c1.Level,c1.id,c1.sponsor_id,c1.sponser_level FROM agent_details c1 WHERE c1.id='".$agent."'";
//echo $s;
$r = mysql_query($s);
// echo $user_level=$fetch['sponser_level'];
//echo $intro_id;
$sponser =array();
if(mysql_num_rows($r) > 0) {
//echo "hai";
# It has children, let's get them.
while($fetch=mysql_fetch_assoc($r)) {
# Add the child to the list of children, and get its subchildren
// $sponser [$fetch['id']] = categoryChild($fetch['sponsor_id'],$property);
$sponser[] = categoryChild($fetch['sponsor_id'],$property);
// commissionCal($property,$sponser);
}
print_r($sponser); // this returns Array ( [0] => Array ( ) ) Array ( [0] => Array ( ) [1] => Array ( [0] => Array ( ) ) )
}
return $sponser;
}
function commissionCal($property,$sponser_level)
{
//print_r($sponser_level);
$get_level="SELECT a1.sponser_level,a2.agent_level_id,a2.property,a2.percentage FROM agent_details a1,agent_level_amount a2 WHERE a2.property='".$property."' AND a2.agent_level_id='". $sponser_level."' ";
}
function callFunction($agent,$property)
{
$sponser_level=categoryChild($agent,$property);
//print_r($sponser_level);
commissionCal($property,$sponser_level);
}
callFunction($agent,$property);
I want to get the sponsor's level to feed it in next function which is having select query to retrieve the percentage value of corresponding level.
Please don't tell MySQL is deprecated - it's just for testing.