<?php include("session_start.php");
include("session_check.php");
include("database.php");
if($_GET['td1']!="")
{	
	$td1=$_GET["td1"];
	
	$sb2=$_GET["sb2"];
	$sbv=explode(",",$sb2);
	// print_r($sbv);
	$cnt=count($sbv);
	$ct1=0;
	//$str1='';
	while($cnt!=0)
	{
		if($sbv[$ct1]!="")
		{
			//echo "hi";
			$str=$sbv[$ct1];
			 $str1="'".$str."'".",";
		}
		$str2.=$str1;
		$ct1++;
		$cnt--;
		
	}
	$str3=$str2;
	//print_r($str3);
	$str4=substr_replace($str3 ,"",-1);
	$sql1= mysql_fetch_array(mysql_query("select * from master_ward where wid='$td1'"));
	//echo "SELECT * FROM input_form WHERE ward_office= '".$sql1['wvalue']."' and ward IN($str4)";
	//echo "select t2.tree_name from input_form as t1 left join info as t2 on t1.id = t2.aid where ward_office= '".$sql1['wvalue']."' and ward IN($str4)";
	$sql="select t2.tree_name,t2.scientific_name from input_form as t1 left join info as t2 on t1.id = t2.aid where ward_office= '".$td1."' and ward IN($str4) ";
	//echo $sql;
	$rest=mysql_query($sql);
	$num = @mysql_num_rows($rest); if($num >0){?>
    <a href="print_total_tree_subward_report.php?td1=<?php echo $td1?>&sb2=<?php echo $sb2?>"> <input type="button" bgcolor="#a9c1de"  name="print" id="print" value="Print"  style="text-decoration:none" class="button_c" onClick=""></a>
    
    <table border="1" cellpadding="2" cellspacing="2" width="60%" align="center" bordercolor="#bcd5e7" >
	   
	  <tr>
    	
               <td align="left"><font class="font4"><b>Tree Name</font></td>
               <td align="left"><font class="font4"><b>Scientific Tree Name</font></td>
 
        </td>
     </tr>
     <?php
   while ($row =@mysql_fetch_object($rest)) 
{
	$query_tree = mysql_query("select * from tree_name where tid= '".$row->tree_name."'");
	$result_tree = mysql_fetch_array($query_tree);
	echo "<tr>";
	
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$result_tree['tree_name']."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$result_tree['scientific_name']."</font></div></td>";

;
}
?>

</table>
    
<?php }else
{
	echo "No Records To Display";
}
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Survey Application</title>
</head>

<body>
</body>
</html>