dushtu.bor 0 Newbie Poster

Hi, here is my codes, its doing show binary tree. But the problem is, maximum ids show easily, but some ids are not showing anything, give a blank page, totally blank, without any error. How to check where is wrong? First parent id not showing anything, if i run it for first id, it give the blank page without any error. Why this?

<?php

if(!defined('GEN4_PROCESS')) { exit(); }
 
if($loggedin) {

/* my code started from here */	

	$ref_title = "Tree view";

	$total =0;
	
	if($_POST) 
		$user = $_POST['username'];
	else   $user = $ir['username'];	
	
	if ($user == "Open")
	$user = $ir['username'];
		

$uq="select username,lname,rname from users where username='$user'";
$ur=mysql_query($uq);

if (mysql_num_rows($ur) == 0) {
    $u1= "Open";
    $lq= "Open";
    $rq= "Open";
}

$row1 = mysql_fetch_assoc($ur);
    $u1=$row1["username"];
    	if ($u1 == NULL)
	$u1 = "Wrong-ID";
    $lq = "Open";
    $rq = "Open";
    $meml = $row1["lname"];
    $memr = $row1["rname"];
	if ($row1["lname"]!= NULL) 
	$lq = $row1["lname"];
	
	if ($row1["rname"]!= NULL) 
	$rq=$row1["rname"];

$llq="select lname,rname from users where username='$lq'";
$llr=mysql_query($llq);

if (mysql_num_rows($llr) == 0) {
	$l2 = "Open";
	$r2 ="Open";
}

$row2 = mysql_fetch_assoc($llr);
	$l2 = "Open";
	$r2 = "Open";
		if ($row2["lname"]!= NULL)
		$l2 = $row2["lname"];

		if ($row2["rname"] != NULL)
    		$r2 = $row2["rname"];

$rrq="select lname,rname from users where username='$rq'";
$rrr=mysql_query($rrq);

if (mysql_num_rows($rrr) == 0) {
    $l3 = "Open";
    $r3 = "Open";
}

$row3 = mysql_fetch_assoc($rrr);
	$l3 = "Open";
	$r3 = "Open";
		
		if ($row3["lname"] != NULL)
		$l3 = $row3["lname"];

		if ($row3["rname"] != NULL)
		$r3 = $row3["rname"];
/* my code finished */

$sql = "SELECT * FROM `upg_options` WHERE uo_id = '".$dome->filter($_GET['upg'])."'";
$q = mysql_query($sql);
$upg = @mysql_fetch_assoc($q);
	
	require_once("menu.php");
	$id = $dome->filter($_GET['upg']);
	$upgrades = mysql_query("SELECT * FROM `upg_options`");
	$upgrade = "<select name=\"upg\" onChange=\"window.location = '?upg='+this.value+''\">";
	while($upgr = mysql_fetch_array($upgrades)) {
		$select = "";
		if($id==$upgr['uo_id']) $select = " selected=\"selected\"";
		$upgrade .= "
					<option value=\"{$upgr['uo_id']}\"$select>{$upgr['uo_name']}</option>";
	}
	$upgrade .= "
				</select>";
	
	$balance = round($ir['rbalance'], 2);

	$contents .= "
	<div id=\"content\" class=\"upgrade\">
		{$menu}

		<div id=\"inner\">";

			if($error) $contents .= "
			<div class=\"error\" style=\"min-height: 20px; max-height: 100px;\" >{$error}</div>";
			if($success) $contents .= "
			<div class=\"success\" style=\"min-height: 50px; max-height: 100px;\" >{$success}</div>";

			$contents .= "
			<div class=\"left\">
<!-- My another code start here for table -->
				<h1>Tree view</h1>

				

	<table>
		<tr>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$u1."  /></td></form>
		</tr>
	</table>

	<table>	
	<tr>
		<td align=\"center\"><img src=\"band2.gif\" ALT=\"lr\"></img></td>
	</tr>
	</table>

	<table>
	<tr>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$lq."  /></td></form>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$rq."  /></td></form>
	</tr>
	</table>

	<table>
	<tr>
		<td align=\"center\"><img src=\"band3.gif\" ALT=\"lr\"></img></td>
		<td align=\"center\"><img src=\"band3.gif\" ALT=\"lr\"></img></td>
	</tr>
	</table>

	<table>
	<tr>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$l2."  /></td></form>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$r2."  /></td></form>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$l3."  /></td></form>
		<form method=\"post\" action=\"tree.php\"><td align=\"center\"><input type=\"submit\" name=\"username\" value=".$r3."  /></td></form>
	</tr>
	</table>
	
	
<!-- Finish table code 	-->

		<form method=\"post\" action=\"tree.php\">";
		
				$contents .= "

				<div class=\"buttons\"><input type=\"submit\" value=\"Back\"  /></div>";
			$contents .= "
			</form>
				
			</div>


<!-- For search area -->
			<form method=\"post\" action=\"tree.php\">";
	
				$contents .= "
				<h2>Serach in your own tree:</h2>
				<div class=\"label\">
					<p><label><input type=\"text\" name=\"username\" id=\"textfield\"></label></p>
				</div>	
				<div class=\"buttons\"><input type=\"submit\" value=\"search\"  /></div>";
// Finish search area		
		$contents .= "
			</form>

			<div class=\"right\">
				<h1>Your Total Matching Statistics</h1>";

function getTotalLeg($memid){	
$sql="select lname, rname from users where username = '".$memid."' LIMIT 1";

$res=mysql_query($sql) or die(mysql_error());
$rowf = mysql_fetch_assoc($res) or die(mysql_error());

global $total;
if ($rowf["lname"] != NULL)
$total = $total + 1; 
if ($rowf["rname"] != NULL)
$total = $total + 1; 

            if($rowf["lname"] != NULL) {
                
                getTotalLeg ($rowf["lname"]); }
            if($rowf["rname"] != NULL){
                
                getTotalLeg ($rowf["rname"]); }
            
return $total;
}


				$totall = 0;
				if($meml != NULL){
				global $total;
				$total = 0;
				$totall = getTotalLeg($meml); 
				$totall = $totall + 1;
				}
				$totalr = 0;
				if($memr != NULL){
				global $total;
				$total = 0;
				$totalr = getTotalLeg($memr); 
				$totalr = $totalr + 1;
				}
				
				$contents.= "
				<h1>Total Left = ".$totall." </h1>
				<h1>Total Right = ".$totalr." </h1>
				

				
				
			</div>

		</div>		
	</div>";
			
			
} else {
	$contents .= "</div>";
	$do->login_return();
}

?>

The tree is first id 1, which have no parents.
Next id 2, parent id 1.
Next id 3, parent id 1.
next id 4, parent id 2.
next id 5, parent id 2.
next id 6, parent id 3.
next id 7, parent id 3.
next id 8, parent id 4.
next id 9, parent id 4.
next id 10, parent id 5.
next id 11, parent id 5.
next id 12, parent id 6.
next id 13, parent id 6.
next id 14, parent id 7.
next id 15, parent id 7.

Now, in this, 1,2,4,8 not working, working ids: 3,5,6,7,9,10,11,12,13,14,15.
What the fun in this codes?