<?php session_start();  //Developed by ITechScripts
error_reporting(0);
if(strlen($_SESSION['adminuser'])==0) {
	echo '<meta http-equiv="refresh" content="0;url=index.php">';
	exit();
}
?>
<style type="text/css">
<!--
.style1 {
	color: #666666;
	font-weight: bold;
}
.style3 {color: #666666; font-size: 11px; font-family:Arial, Helvetica, sans-serif}
-->
</style><?php
require 'include/configurations.php'; // ITECHBIDS Configuration File
$limitsize=5;
$currec=$_GET[currec];
	function getReferral_details($userid,$level) {
		$select_referral_query="select * from member_details where intro_id=$userid";
		$select_referral_result=mysql_query($select_referral_query);
		/* $select_level_query="select max(level_id) from ref_levels";
		$select_level_result=mysql_query($select_level_query);
		$select_level_row=mysql_fetch_array($select_level_result);
		$level_limit=$select_level_row[0]; */
		if(mysql_num_rows($select_referral_result)>0) {
		$level+=1;
		while($select_referral_row=mysql_fetch_array($select_referral_result))
		 {
				echo "<tr align=center><td>$level</td><td>".$select_referral_row['user_name']."</td><td>".$select_referral_row['date_of_registration']."</td></tr>";
						$intro_id=$select_referral_row['user_id'];
						getReferral_details($intro_id,$level);
			}
		}
		else {
			//echo "<tr><td colspan=3>No Users found in your Downline</td></tr>";
		}
	}
?>
>
<table border="0" align="center"><tr valign="top"><td valign="top"><?php
	require 'include/header.php';
	$type=$_GET['type'];
	$id=$_GET['id'];
	$mode=$_GET['mode'];
?>  



<table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
<tr align="center">
<td align="center"><a href="useritechds.php?id=<?=$id?>&type=gen">General</a></td>
<td><a href="useritechds.php?id=<?=$id?>&type=per">Personal</a></td>
<td><a href="usertrans.php?id=<?=$id?>">Transaction Details</a></td> 
</tr><tr align="center">
<td><a href="userbid.php?id=<?=$id?>">Bid Details</a></td>
<td><a href="userref.php?id=<?=$id?>">Refferal Details</a></td>
<td><a href="addfunds.php?id=<?=$id?>">Add Bids</a></td>
</tr>
</table>
</td></tr>
<?
	if($type=="gen") {
		$mem_sql="select * from member_details where user_id=$id";
		$mem_res=mysql_query($mem_sql);
		$mem_row=mysql_fetch_array($mem_res);
		$username=$mem_row['user_name'];
		$member_since=$mem_row['date_of_registration'];
		$member_since=explode('-',$member_since);
		$member_since=date('M-d-Y',mktime(0,0,0,$member_since[1],$member_since[2],$member_since[0]));
		$won_sql="select * from site_bids a,auction_details b where a.user_id=$id and a.productid=b.productid and a.user_pos='Yes'";
        $won=mysql_query($won_sql);
        $total_won=mysql_num_rows($won);
		$live_sql="select * from auction_details where user_id=$id and status='Active'";
        $live=mysql_query($live_sql);
		$total_live=mysql_num_rows($live);
		$bid_sql="select * from site_bids where user_id=$id and user_pos='No'";
        $bid=mysql_query($bid_sql);
        $total_bid=mysql_num_rows($bid);
		$lost_sql="select * from site_bids a,auction_details b where a.user_id=$id and a.user_id=b.user_id and a.productid=b.productid and a.user_pos='No'";
 		$lost=mysql_query($lost_sql);
		$total_lost=mysql_num_rows($lost);
		$watch_sql="select * from watch_list where user_id=$id";
 		$watch=mysql_query($watch_sql);
		$total_watch=mysql_num_rows($watch);
		$sold_sql="select * from site_bids a,auction_details b where b.user_id=$id and a.productid=b.productid and quantity_sold > 0";
 		$sold=mysql_query($sold_sql);
		$total_sold=mysql_num_rows($sold);

		$norec="No Items Found";
				
?>
<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="75%">
<tr><td align="center" colspan="2" class="tddis"><b><font size="+1">Auction Details of <?=$username?></font></b></td></tr>
<tr><td  class="tddis"><b>Member Since</b></td><td class="tddis"><?=$member_since?></td></tr>
<tr><td class="tdmain" colspan="2"><font size="+1"><b>Selling Details</b></font></td></tr>
<tr><td class="tddis"><b># of Sold Items</b></td><td class="tddis"><?php if($total_sold!=0) echo $total_sold; else echo $norec; ?>
</td></tr>
<tr><td class="tddis"><b># of Live Items</b></td><td class="tddis"><?php if($total_live!=0) echo $total_live; else echo $norec; ?>
</td></tr>
<tr><td class="tdmain" colspan="2"><font size="+1"><b>Buying Details</b></font></td></tr>
<tr><td class="tddis"><b># of Bidding Items</b></td><td class="tddis"><?php if($total_bid!=0) echo $total_bid; else echo $norec; ?>
</td></tr>
<tr><td class="tddis"><b># of Won Items</b></td>
<td class="tddis"><?php if($total_won!=0) echo $total_won; else echo $norec; ?></td></tr>
<tr><td class="tddis"><b># of Watching Items</b></td>
<td class="tddis"><?php if($total_watch!=0) echo $total_watch; else echo $norec; ?></td></tr>
<tr><td class="tddis"><b># of Lost Items</b></td>
<td class="tddis"><?php if($total_lost!=0) echo $total_lost; else echo $norec; ?>
</td></tr>
<tr><td colspan="2">&nbsp;</td>
</tr>
</table>
</td></tr>
<?
	}
	if($type=="per")
    {
	$sql="select * from member_details where user_id=$id";
	$result=mysql_query($sql);
	$row=mysql_fetch_array($result);
	
	$username=$row['user_name'];
	$firstname=$row['first_name'];
	$lastname=$row['last_name'];
	$memberemail=$row['email'];
	 /* $introid=$row['intro_id'];
	
	$intro_sql="select * from members where member_id=$introid";
	$intro_res=mysql_query($intro_sql);
	$intro_row=mysql_fetch_array($intro_res);
	$introname=$intro_row['username']; */
	if(!$introname) $introname='None'; 
	$address=$row['address'];
	$city=$row['city'];
	$state=$row['state'];
	$country=$row['country'];
	$coun_sql="select * from site_countries where country_id=$country";
	$coun_res=mysql_query($coun_sql);
	$coun_row=mysql_fetch_array($coun_res);
	$country=$coun_row['country'];
	$zipcode=$row['pin_code'];	
	$work_phone=$row['work_phone'];
	$home_phone=$row['home_phone'];
	$date_join=$row['date_of_registration'];
	$payment_method=$row['payment_method'];
	$last_login_date=$row['last_login_date'];
	$ip=$row['ip_address'];
	 /* $pay_sql="select * from payment_process where payment_id=$payment_method";
	$pay_res=mysql_query($pay_sql);
	$pay_row=mysql_fetch_array($pay_res);
	$payment=$pay_row['payment_name']; */
	
	$account_no=$row['account_no'];
?>
<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="0" width="75%">
<tr><td align="center" colspan="2"><b><font size="+1">
Personal Details of <?=$username?></font></b></td></tr>
<tr><td><b>Username</b></td><td><b><?=$username?></b></td></tr>
<tr><td><b>Firstname</b></td><td><b><?=$firstname?></b></td></tr>
<tr><td><b>Lastname</b></td><td><b><?=$lastname?></b></td></tr>
<tr><td><b>Member Email</b></td><td><b><?=$memberemail?></b></td></tr>
<tr><td><b>Referred y</b></td><td><b><?=$introname?></b></td></tr>
<tr><td><b>Address</b></td><td><b><?=$address?></b></td></tr>
<tr><td><b>City</b></td><td><b><?=$city?></b></td></tr>
<tr><td><b>State</b></td><td><b><?=$state?></b></td></tr>
<tr><td><b>Country</b></td><td><b><?=$country?></b></td></tr>
<tr><td><b>Zipcode</b></td><td><b><?=$zipcode?></b></td></tr>
<tr><td><b>IP Address</b></td><td><b><?=$ip?></b></td></tr>
<tr><td><b>Home_Phone</b></td><td><b><?=$home_phone?></b></td></tr>
<tr><td><b>Work_Phone </b></td><td><b><?=$work_phone?></b></td></tr>
<tr><td><b>Date of Join</b></td><td><b><?=$date_join?></b></td></tr>
<tr><td><b>Last login Date </b></td><td><b><?=$last_login_date; ?></b></td></tr>
</table></td></tr><?
	}	
	 if($type=="sell")
	  {
			$member_sql="select * from member_details where user_id=$id";
			$member_result=mysql_query($member_sql);
			$member_row=mysql_fetch_array($member_result);
			$username=$member_row['user_name'];
			$postsql="select * from auction_details where user_id=$id and status='Active'";
            $sell=mysql_query($postsql);
        if($mode=='live')
			$postsql="select * from auction_details where user_id=$id and status='Active'";
		else if($mode=='sold') 
			$postsql="select * from auction_details where user_id=$id and quantity_sold > 0";
		else if($mode=='unsold') 
			$postsql="select * from auction_details where user_id=$id and quantity_sold=0";
			$sell=mysql_query($postsql);
			$total_records=mysql_num_rows($sell);
			if($total_records>0)
{ 
//get the total records
if(strlen($currec)==0) 
$currec = 1;  
$start = ($currec - 1)*$limitsize;
$end = $limitsize;
$postsql .=" limit $start,$end";
$sell=mysql_query($postsql);
} 
?>
<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
      <tr> 
        <td> <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
            <tr> 
              <td> <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
                  <tr> 
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=sell&mode=live">Live 
                      Items</a></td>
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=sell&mode=sold">Sold 
                      Items</a></td>
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=sell&mode=unsold">Unsold 
                      Items</a></td>
                  </tr>
                </table></td>
            </tr>
            <tr> 
              <td align="center" colspan="2"><b><font size="+1"> 
                <? if($mode!='')
{ 
$mode=$mode." Items";

?>
                <?=ucwords($mode)?>
                <?
}
else
{
?>
                Selling 
                <?
}
?>
                Details of 
                <?= $username; ?>
                </font></b></td>
            </tr>
            <?
 if(($total_records)>0)
{
?>
            <tr> 
              <td> <table cellpadding="5" cellspacing="0" align="center" width="540">
                  <?
$net=($currec-1*$limitsize+$end)-$total_records;
$dis=$limitsize+$start;
if($net <= 0) $net=$end;
if($dis<=$total_records)
{
?>
                  <tr align="left"> 
                    <td> <font size="2"> Showing <? echo $start+1; ?> <? echo " - ". $dis; ?> 
                      of <? echo $total_records; ?> Items </font> </td>
                    <? 
}
else 
{
?>
                    <br>
                    <br>
                  <tr align="left"> 
                    <td> <font size="2" class="font_tit_color">Showing <? echo $start+1;?> 
                      of <? echo $total_records; ?> Item </font></td>
                    <?
if($currec != 1)
{ 
$ver=1;
?>
                    <td> <a href="useritechds.php?currec=<?=($currec - 1);?>&type=sell&id=<?=$id?>" style="text-decoration:none;"> 
                      <font size="2" face="Arial, Helvetica, sans-serif" class="font_tit_color">Previous 
                      </font></a></td>
                    <?
} 
}  
?>
                    <? if($currec != 1 and $ver!=1)
{ 
?>
                    <td><a href="useritechds.php?currec=<?=($currec - 1);?>&type=sell&id=<?=$id?>" style="text-decoration:none;"> 
                      <font size=2 class="font_tit_color" face="Arial, Helvetica, sans-serif">Previous 
                      </font></a></td>
                    <?
} 
$net=$total_records-($currec*$limitsize+$end) + $end;
if($net >$limitsize) $net=$limitsize;
if($net <= 0) $net=$end;
if($total_records > ($start + $end)) 
{
?>
                    <td> <a href="useritechds.php?currec=<?=($currec + 1);?>&type=sell&id=<?=$id?>" style="text-decoration:none;" > 
                      <font size=2 color="#003366" face="Arial, Helvetica, sans-serif"> 
                      Next </font> </a></td>
                    <?
 } 
?>
                  </tr>
                  <?
}
?>
                  <?
	if(mysql_num_rows($sell)>0) 
	{
?>
                  <tr> 
                    <td colspan="2"> <table border="0" align="center" width="100%" cellpadding="5" cellspacing="0" class="ft">
                        <tr > 
                          <td>&nbsp;</td>
                          <td><b>Item</b></td>
                          <td><b>Current Price</b></td>
                          <td><b>Quantity</b></td>
                          <td><b>Ends</b></td>
                          <td><b># of Bids</b></td>
                        </tr>
                        <? 
	while($postrow=mysql_fetch_array($sell)) {
		$sql="select * from auction_details where productid=".$postrow[productid];
		$result=mysql_query($sql);
		$row=mysql_fetch_array($result);
		$user_sql="select * from member_details where user_id=".$row['user_id'];
		$user_res=mysql_query($user_sql);
		$user=mysql_fetch_array($user_res);
		$productid=$row[productid];
		$bid_sql="select * from site_bids where productid=".$productid;
		$bid_res=mysql_query($bid_sql);
		$bid=mysql_fetch_array($bid_res);
		$total_bid=mysql_num_rows($bid_res);
		$bid_date=$bid['bidding_date'];
		$current_price=$bid['bidding_amount'];
		$tot_sql="select count(*) from site_bids where productid=".$productid;
		$tot_res=mysql_query($tot_sql);
		$tot=mysql_fetch_array($tot_res);
		if($total_bid>0)
		{
		$current_price=$bid['bidding_amount'];
		}
		else
		{
        $current_price=$row['min_bid_amount'];
		}
		$expire_date=$row['expire_date'];
  		require 'ends.php';

if($c==1)
  {
  $c=0;
  ?>
 <tr > 
                          <? 
  }
  else
  {
  $c=1;
  
  ?>
                        <tr bgcolor="white"> 
                          <? 
   }
  ?>
                          <td> <a href="item_itechds.php?id=<? echo $row['productid']; ?>" alt="Click here to view item Description"> 
                            <?
	if(!empty($row[picture1]))
	{ 
	?>
                            </a><a href="item_itechds.php?id=<? echo $row['productid']; ?>">
							<img height="40" width="40" src="../images/<? echo $row['picture1']; ?>" border=0></a> 
                            <?
	 }
	 else
	 {
	 	?>
                            <a href="item_itechds.php?id=<? echo $row['productid']; ?>">
							<img height="40" width="40" src="../images/no-image.gif" border=0></a> 
                            <? 
 }
  ?>
                          </td>
                          <td> <a href="item_itechds.php?id=<?  echo $row['productid']; ?>" id="link1"> 
                            <?  echo $row['producttitle']; ?>
                            </a> </td>
                          <td> 
                            <?  echo $current_price; ?>
                          </td>
                          <td> 
                            <?= $row[Quantity]?>
                          </td>
                          <td> 
                            <?=$string_difference?>
                          </td>
                          <td> 
                            <? 
    if($tot[0]==0)
	{
	$tot="No Bid";
    echo $tot;
	}
	else
	{
	$tot=$tot[0]; ?>
                            <a href="bid_itechd.php?productid=<? echo $row['productid']; ?>" id="link1" alt="Click here to view Bid details"> 
                            <?  echo $tot; ?>
                            </a> 
                            <?
	}
	?>
                          </td>
                        </tr>
                        <?
	}
	}
	else {
?>
                        <tr> 
                          <td colspan="7" align="center"><font size=+1><b>There is no items display 
                            in this view</b></font></td>
                        </tr>
                        <?
	}
?>
                      </table></td>
                  </tr>
                </table> 
          </table>
          <?
	}
	  if($type=="buy")
	 {
			$member_sql="select * from member_details where user_id=$id";
			$member_result=mysql_query($member_sql);
			$member_row=mysql_fetch_array($member_result);
			 $username=$member_row['user_name'];
			$bid_sql="select * from site_bids where user_id=$id and user_pos='No'";
			$bid=mysql_query($bid_sql);
			$total_records=mysql_num_rows($bid);
								
		if(!$mode) $mode='bid';
		if($mode=='bid')
			 $buy_sql="select * from site_bids where user_id=$id and user_pos='No'";
		else if($mode=='won') 
			  $buy_sql="select * from site_bids a,auction_details b where a.user_id=$id and a.productid=b.productid and a.user_pos='Yes'";
		else if($mode=='notwin') 
			  $buy_sql="select * from site_bids a,auction_details b where a.user_id=$id and a.productid=b.productid and a.user_pos='No' and b.status='Closed'";
			$buy=mysql_query($buy_sql); 
?>
      <tr> 
        <td> <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
            <tr> 
              <td> <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
                  <tr align="center"> 
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=buy&mode=bid">Bidding Items</a></td>
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=buy&mode=won">Won Items</a></td>
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=buy&mode=notwin">Lost Items</a></td>
                  </tr>
                </table></td>
            </tr>
            <tr> 
              <td align="center" colspan="2" width="110%"><b><font size="+1"> 
<? if($mode == "bid")
{
$wrmode = "Bidding Items";
}
    
if($mode == "won")
{
$wrmode = "Won Items";
}

if($mode == "notwin")
{
$wrmode = "Lost Items";
}
?>            "<?= ucwords($wrmode)?>" of 
                <?=$username?>
                </font></b></td>
            </tr>
            <? 
	$buy_tot=mysql_num_rows($buy);
	if($buy_tot>0) 
	{ 
	?>
            <tr> 
              <td colspan="2"> 
			  <table border="0" align="center" width="100%" cellpadding="5" cellspacing="0" class="ft">
                  <tr > 
                    <td><b>Item</b></td>
                    <td><b>Bid Amount</b></td>
                    <td><b>Quantity</b></td>
                    <td><b>Total Amount</b></td>
                    <td><b>Bid Date</b></td>
                    <td><b>Ends</b></td>
                  </tr>
                  <?
      $c=1;
	while($bid_row=mysql_fetch_array($buy))
	 {
		 $sql="select * from auction_details where productid=".$bid_row[productid];
		$result=mysql_query($sql);
		$row=mysql_fetch_array($result);
		 $user_sql="select * from member_details where user_id=".$row['user_id'];
		$user_res=mysql_query($user_sql);
		$user=mysql_fetch_array($user_res);
		$productid=$row[productid];
		 $bid_sql="select * from site_bids where productid=".$productid;
		$bid_res=mysql_query($bid_sql);
		$bid=mysql_fetch_array($bid_res);
		$total_bid=mysql_num_rows($bid_res);
		$bid_date=$bid['bidding_date'];
		$current_price=$bid['bidding_amount'];
		$tot_sql="select count(*) from site_bids where productid=".$productid;
		$tot_res=mysql_query($tot_sql);
		$tot=mysql_fetch_array($tot_res);
		if($total_bid>0)
		{
		$current_price=$bid['bidding_amount'];
		}
		else
		{
		$current_price=$row['min_bid_amount'];
		}
		$expire_date=$row['expire_date'];
  		require 'ends.php';

		
		
		

if($c==1)
  {
  $c=0;
  ?>
                  <tr bgcolor="white"> 
                    <? 
  }
  else
  {
  $c=1;
  
  ?>
                  <tr > 
                    <? 
   }
  ?>
                    <td> 
                      <?= $row[producttitle]; ?>
                    </td>
					<td> 
                      <?=$bid[bidding_amount]; ?>
                    </td>
                    
                    <td> 
                      <?=$bid[quantity];?>
                    </td>
					
					<td><?= ($bid[bidding_amount] * $bid[quantity]) ?></td>
					<td> 
                      <?= $bid_date; ?>
                    </td>
                    <td> 
                      <?= $string_difference; ?>
                    </td>
                    
                  </tr>
                  <?
	}
	}
	else if(mysql_num_rows($buy)==0) 
	{
?>
                  <tr> 
                    <td colspan="7" align="center"><font size=+1><b>There is no items display in 
                      this view</b></font></td>
                  </tr>
                  <?
	}
?>
                </table></td>
            </tr>
          </table></td>
      </tr>
      <?
	}
/*	if($type=='feed')
	 {
			$member_sql="select * from member_details where user_id=$id";
			$member_result=mysql_query($member_sql);
			$member_row=mysql_fetch_array($member_result);
			$username=$member_row['user_name'];
			
?>
      <tr> 
        <td> <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
            <tr> 
              <td> <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
                  <tr> 
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=bon&mode=bonus">Bonus</a></td>
                    <td align="center"><a href="useritechds.php?id=<?=$id?>&type=bon&mode=penalty">Penalty</a></td>
                  </tr>
                </table></td>
            </tr>
            <tr> 
              <td align="center" colspan="2"><b><font size="+1"> 
                <?=ucwords($mode)?>
                Details of 
                <?=$username?>
                </font></b></td>
            </tr>
            <tr> 
              <td colspan="2"> <table border="0" align="center" width="100%" cellpadding="5" cellspacing="2" class="ft">
                  <tr> 
                    <td><b>Amount</b></td>
                    <td><b> 
                      <?=ucwords($mode)?>
                      Date</b></td>
                    <td><b>Description</b></td>
                  </tr>
                  <?
	if(mysql_num_rows($result)>0) {
	while($row=mysql_fetch_array($result)) {
		$amount=$row['amount'];
		$date=$row['date'];
		$description=$row['description'];
?>
                  <tr> 
                    <td> 
                      <?=$amount?>
                    </td>
                    <td> 
                      <?=$date?>
                    </td>
                    <td> 
                      <?=$description?>
                    </td>
                  </tr>
                  <?
	}
	}
	else {
?>
                  <tr> 
                    <td colspan="7" align="center">No 
                      <?=ucwords($mode)?>
                      Found</td>
                  </tr>
                  <?
	}
?>
                </table></td>
            </tr>
          </table></td>
      </tr>
      <?
	} */
	if($type=='ref') {
			$member_sql="select * from member_details where user_id=$id";
			$member_result=mysql_query($member_sql);
			$member_row=mysql_fetch_array($member_result);
			$username=$member_row['user_name'];
?>
      <tr>
        <td height="157"><table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
            <tr> 
              <td align="center" colspan="2"><b><font size="+1">Referrals Details 
                of 
                <?=$username?>
                </font></b></td>
            </tr>
            <tr align="center"> 
              <td> <table border="0" align="center" width="80%" cellpadding="5" cellspacing="2" class="ft">
                  <tr align="center"> 
                    <td><b>Level</b></td>
                    <td><b>Username</b></td>
                    <td><b>Join Date</b></td>
                  </tr>
                  <? getReferral_details($id,0) ?>
                </table></td>
            </tr>
          </table>
      <tr align="center"> 
        <td height="35"> 
 <?
  }
  else if($type=='account')
  {
            $member_sql="select * from member_details where user_id=$id";
			$member_result=mysql_query($member_sql);
			$member_row=mysql_fetch_array($member_result);
			$username=$member_row['user_name'];
 ?>
<table border = "0" cellpadding="2" cellspacing="0" width=550>
<tr height=20><td></td></tr>
	<?
	//calculate total Fund amount
	$query="select * from addfunds where member_id='$id'";
	$table=mysql_query($query);
	$total_fund_amount=0;
	if(mysql_num_rows($table)>0)
	while($row=mysql_fetch_array($table))
	$total_fund_amount +=$row['fund_amount'];
     //calculate total referral amount
	 $query="select * from referral_commission where user_id='$id'";
	 $table=mysql_query($query);
	$total_referral_commission=0;
	
	if(mysql_num_rows($table)>0)	
	{
	while($row=mysql_fetch_array($table))
	$total_referral_commission +=$row['referral_commission'];
     }
	//calculate credit
	$query="select * from user_account where user_id='$id'";
    $table=mysql_query($query);
	$credit=0;
	if(mysql_num_rows($table)>0)	
	{
	while($row=mysql_fetch_array($table))
	$credit +=$row['amount'];
     }
	?>
	<tr>
	<td align="center">
	     <table width="80%" class="table_border">
		 <tr class="mylist" height=30><td align="center" colspan="2"><b><font size="+1">Account Details of <?= $username ?></b></font></td></tr>
		 <tr height=30><td><br><b>Available Cash</td>  <td><b>$ <? echo $total_fund_amount; ?></td></tr>
		 <tr height=30><td><b>Referral Income</td> <td><b>$ <? echo $total_referral_commission; ?></td></tr>
		 <tr height=30><td><b>Credits by posting Items</td> <td><b>$ <? echo $credit ?></td></tr>
		 <tr><td colspan="2"><hr></td></tr>
		 <tr height=30><td><b>Total Amount</td>
		  <td><b>$ <? echo ($total_fund_amount + $total_referral_commission -$credit);?></td></tr>
	     </table>
	</td>
	</tr>
	</table>		  
<?
}
?>		  
		  
		  
     </td></tr></table>
</body>
</html>
<?
	require 'include/footer.php';
?>