<?php

		include("session_start.php");

		include("session_check.php");

		include("database.php");

	$td1=$_GET["td1"];
	$sb2=$_GET["sb2"];
	$society = $_GET["society"];

?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?php 
			$subward_query = "select * from master_ward_drop where did = '".$sb2."'";
			$res_subward = mysql_query($subward_query);
			$res_subward1 = mysql_fetch_array($res_subward);
			
		
			if($td1 != '' && $sb2 != ''){
				if($society == ''){}
				else{ echo "Tree Records of ". $society;}	
			}
			
			if($td1 != ''){
				if($sb2!='' && $society == ''){
						echo "Tree Records of ". $res_subward1['dvalue'];
					}
				}
			if($td1 == '' && $sb2 == ''){
				if($society!= ''){
					echo "Tree Records of ". $society;
					}
				}
			
		
		 ?></title>

<link rel="stylesheet" type="text/css" href="css/style.css" />

<!--<link rel="stylesheet" type="text/css" href="css/page.css">

<link href="css/admincss.css" rel="stylesheet" type="text/css">

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />
-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="js/ddsmoothmenu.js">

</script>



<script type="text/javascript">



/*ddsmoothmenu.init({

	mainmenuid: "smoothmenu1", //menu DIV id

	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"

	classname: 'ddsmoothmenu', //class added to menu's outer DIV

	//customtheme: ["#1c5a80", "#18374a"],

	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]

})
*/






</script>

<style type='text/css' media='print'>

#prnt {display : none}

#header{display:none;}

#footer{display:none;}

#back {display : none}



</style>

</head>



<body class="body">



<div id="wrap" >

  

  

  <div id="top">

    <?php /*?><?php include("header.php"); ?><?php */?>

    <!--<div id="ban"><table width="1004" align="left"  >

  <tr>

    <td width="234"  align="left"  valign="top" ><img src="images/logoss.jpg" border="0" /></td>

    <td  valign="top" style="padding-top:5px;" width="758"  align="right" ><table align="left" width="707">

  <tr>

    <td width="386" align="left"><div ><a href="#" id="bantext1">REQUEST A DEMO</a></div></td>

    <td width="167" align="left"><div ><a href="#" id="bantext2">DOWNLOADS</a></div></td>

    <td width="138" align="left"><div ><a href="#" id="bantext2">DOWNLOADS</a></div></td>

  </tr>

  <tr>

    <td colspan="3" align="center" class="banquot">Be Smart and Survey Smartly </td>

  </tr>

</table></td>

    

    

  </tr>

</table>

    </div>-->

    

    </div>

    </div>

   <?php /*?><div id="menuholder"><?php include("adminmenu.php"); ?></div><?php */?>

   <div id="contholder" >

   

    

    <!--<div id="nav">

     <ul>

     <li><a href="adminhome.php" id="home_on">HOME</a></li>

        <li><a href="adminproducts.php" id="products_on">PRODUCTS</a></li>

		<li><a href="adminfeatures.php" id="features_on">FEATURES</a></li>

        <li><a href="adminadvantages.php" id="advantages_on">ADVANTAGES</a></li>

        <li><a href="adminhowitworks.php" id="howitworks_on">HOW IT WORKS</a></li>

        <li><a href="adminhelp.php" id="help_on">HELP</a></li>

        <li><a href="admincontactus.php" id="contactus_on">CONTACT US</a></li>

    

    </ul>

    

    </div>-->

    

    

    	<div id="contdata">

    <hr width="90%"></hr>

<center><font face="Verdana" size="2"><b>Property wise report </b></font></center>

<hr width="90%"></hr>

<br>

<table border='0' width='80%'  align='center'  style='font-family:Verdana; font-size:10pt; border-collapse: collapse;'>

	<tr>
    	<td align="center">
        <?php 
			$subward_query = "select * from master_ward_drop where did = '".$sb2."'";
			$res_subward = mysql_query($subward_query);
			$res_subward1 = mysql_fetch_array($res_subward);
			
		
			if($td1 != '' && $sb2 != ''){
				if($society == ''){}
				else{ echo "Tree Records of ". $society;}	
			}
			
			if($td1 != ''){
				if($sb2!='' && $society == ''){
						echo "Tree Records of ". $res_subward1['dvalue'];
					}
				}
			if($td1 == '' && $sb2 == ''){
				if($society!= ''){
					echo "Tree Records of ". $society;
					}
				}
			
		
		 ?>
        
        </td>
    </tr>

    <tr>

        <td align="right">

            <input type="button" value="Print" id="prnt" name="print" onClick="window.print()" align="center" >
	<!--<input type = 'Button' id = 'google' name = 'google' value = 'Google'></input>-->
            <a href="report_ward.php" id="back" style="text-decoration:none; "><input type="button" value="Cancel" name="cancel" >  </a>
            
           <!--<a href="excplayer.php?td1=<?php echo $td1?>&sb2=<?php echo $sb2?>&society=<?php echo $society?>" style="text-decoration:none"><input type="button" value="Export To Excel" name="excel" >  </a>-->
           
           <a href="php_while_plot.php?td1=<?php echo $td1?>&sb2=<?php echo $sb2?>&society=<?php echo $society?>" style="text-decoration:none"><input type="button" value="Download KML" name="google" >  </a>

        </td>

    </tr>

</table>

<br>

<?php

	if($_GET['td1']!="")

{	

	$td1=$_GET["td1"];
	$sb2=$_GET["sb2"];
	$society = $_GET["society"];

	$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)";

	$sql="SELECT * FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name like '%$society%'";
	
	//echo $sql;
	$sql2="select aid from info where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%' )";
	
	$sql3="select count(i.tree_name) as count, t.tree_name as tree_name,t.scientific_name as scientific_name from info i,tree_name t where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%') and t.tid = i.tree_name group by tree_name";
	
	//echo $sql3;

	$sql4 = "select manual_tree as tree_name,count(manual_tree) as count from info where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%') and tree_name = '' and manual_tree <> ''  group by manual_tree";
	
	//echo $sql4."<br>";
	
	$sql5 = "select manual_sci_tree as tree_name,count(manual_sci_tree) as count from info where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%') and tree_name = '' and manual_sci_tree <> ''  group by manual_sci_tree";
	
	//echo $sql5."<br>";
	$query1_2="select * from info where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%')";
	
	//echo $query1_2;
	
	$rest1_2=mysql_query($query1_2);
	
	$res2_2 = "select t.growth_speed as speed,i.age as age from info i, carbon c, tree_name t where i.age = c.age and i.tree_name = t.tid and i.aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%')";
	 $carbon_query_2 = mysql_query($res2_2);
	
	$sql_q="SELECT * FROM input_form WHERE ward= '$sb2'  ";
	$rest=@mysql_query($sql_q);
	$row =@mysql_fetch_object($rest);
	$plot_area = trim($row->plot_area);
	
	$s1= mysql_query("select * from required_tree r, input_form i where r.measure = i.type and id in ( SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%')"); 
	
	$native_query = "select native from info i, tree_name t where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%') and i.tree_name = t.tid and t.native = 'Native'";
	$native_result = mysql_query($native_query);
	$native_num = mysql_num_rows($native_result);
	
	$exotic_query = "select native from info i, tree_name t where aid in(SELECT id FROM input_form WHERE ward_office= '$td1' and ward = '$sb2' and society_name  like '%$society%') and i.tree_name = t.tid and t.native = 'Exotic'";
	$exotic_result = mysql_query($exotic_query);
	$exotic_num = mysql_num_rows($exotic_result);
		
	$result = mysql_query($sql);
	$n = @mysql_num_rows($result);
	$result2 = mysql_query($sql2);
	$result3 = mysql_query($sql3);
	$result4 = mysql_query($sql4);
	$result5 = mysql_query($sql5);
	
	
	//$num = @mysql_num_rows($result2);
	$n4 = @mysql_num_rows($result2);
	$deficit_trees = 0;
	
	while($query=mysql_fetch_array($s1))
	{
		
		$s = "select * from info where aid = '".$query['id']."'";
		//echo $s;
		$r = mysql_query($s);
		$num = @mysql_num_rows($r);
		
		$area = $query['area'];
		//echo $area."<br>";
	
		$tree = $query['tree'];
		//echo $tree."<br>";
		
		$plot_area = $query['plot_area'];
		$ans = ((($plot_area)/($area))*($tree));
		//echo $plot_area."<br>";
		//echo $ans."<br>";
		
		//echo "num--".$num."<br>";
		$de = $ans-$num;
		$deficit_trees = $deficit_trees + $de;
		//echo $deficit_trees;
		
		
	}
	
	
	$n1_1 = @mysql_num_rows($result3);
	$n2_1 = @mysql_num_rows($result4);
	$n3_1 = @mysql_num_rows($result5);
	
	//echo $n1_1."<br>";
	//echo $n2_1."<br>";
	//echo $n3_1."<br>";
	
	$no_of_species_1 = $n1_1+$n2_1+$n3_1;
	if($n > 0){
		
	echo "<table border='1' align='center' cellpadding='2' cellspacing='2'  style='font-family:Verdana; font-size:8pt; border-collapse: collapse; width:50%; margin-bottom:15px; '>";
	
	echo "<tr><th align ='left' >Name of the tree </th>
		<th>No of Trees</th>
	</tr>";
	while($a = mysql_fetch_array($result3))
	{
		
		echo "<tr><td>";
		if($a['tree_name'] != "--")
		{
			echo $a['tree_name']."</td><td> ".$a['count'];	
		}
		else
		{
			echo $a['scientific_name']."</td><td> ".$a['count'];
		}
		echo "</td></tr>";
	}
	while($a = mysql_fetch_array($result4))
	{
		
		echo "<tr><td>";
		echo $a['tree_name']."</td><td> ".$a['count'];
		echo "</td></tr>";
	}
	while($a = mysql_fetch_array($result5))
	{
		
		echo "<tr><td>";
		echo $a['tree_name']."(sci)</td><td> ".$a['count'];
		echo "</td></tr>";
	}
	$total_carbon_2 = 0.0;
	while($row_2 = mysql_fetch_array($rest1_2))
	{
		$res_carbon_query_2 = mysql_fetch_array($carbon_query_2);
	  
		  if($res_carbon_query_2['speed'] != "")
		  {
				$res3_2 = "select `".$res_carbon_query_2['speed']."` from carbon where `age` = '" .$res_carbon_query_2['age']."'";
	  $carbon_2 = mysql_query($res3_2);
	  
	  //echo $res3_1;
		  
	  $res_carbon_2 = mysql_fetch_array($carbon_2);
		  }
		  
		  $total_carbon_2= $total_carbon_2+$res_carbon_2[$res_carbon_query_2['speed']];
		  
	}
	//echo "--".$total_carbon_2."<br>";
	
	
	
	
		echo "<tr><td>";
		echo "<b>Total Number of Trees:</b></td><td> <b>".$n4;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Deficit Trees:</b></td><td> <b>".round($deficit_trees);
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>No of Species Recorded:</b></td><td> <b>".$no_of_species_1;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Carbon Sequestration Potential of Trees: (lbs per year)</b></td><td> <b>".$total_carbon_2;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Number of Native Trees: </b></td><td> <b>".$native_num;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Number of Exotic Trees: </b></td><td> <b>".$exotic_num;
		echo "</b></td></tr>";
		
	echo "</table> <br>";
	
	
	




$sr = 0;

while($row = mysql_fetch_array($result))

  {
	  
	$query_ward = mysql_query("select * from master_ward where wid= '".$row['ward_office']."'");

	$result_ward = mysql_fetch_array($query_ward);

	

	$query_sub = mysql_query("select * from master_ward_drop where did= '".$row['ward']."'");

	$result_sub = mysql_fetch_array($query_sub);

	

	$query_surveyor = mysql_query("select * from login where lid= '".$row['surveyor']."'");

	$result_surveyor = mysql_fetch_array($query_surveyor);
	

  /*echo "<tr>";

	  echo "<td align ='left'>" . $result_ward['wvalue'] . "</td>";

	  echo "<td align ='left'>" . $row['survey_sheet_no'] . "</td>";

	  echo "<td align ='left'>" . $result_sub['dvalue'] . "</td>";

	  echo "<td  align ='left'>" . $row['current_date1'] . "</td>";

	  echo "<td align ='left'>" . $row['sub_area'] . "</td>";

	  echo "<td align ='left'>" . $row['plot_no'] . "</td>";

	  echo "<td align ='left'>" . $row['society_name'] . "</td>";

	  echo "<td align ='left'>" . $row['pincode'] . "</td>";

	  echo "<td align ='left'>" . $row['city'] . "</td>";

	  echo "<td align ='left'>" . $row['state'] . "</td>";

	  echo "<td align ='left'>" . $row['country'] . "</td>";

	  echo "<td align ='left'>" . $row['owner'] . "</td>";

	  echo "<td align ='left'>" . $row['house_no'] . "</td>";

	  echo "<td align ='left'>" . $row['total_area'] . "</td>";

	  echo "<td align ='left'>" . $row['type'] . "</td>";

	  echo "<td align ='left'>" . $row['miscellaneous'] . "</td>";

	  echo "<td align ='left'>" . $row['informer'] . "</td>";

	  echo "<td align ='left'>" . $result_surveyor['username'] . "</td>";

	  

  echo "</tr>";*/
  
  echo "<tr>";
	
	echo "<td colspan='19'>";

	$query1="select * from info where aid='".$row['id']."'";
	$query1_1="select * from info where aid='".$row['id']."'";
	//echo $query1_1;

 	$rest1=mysql_query($query1);
	$rest1_1=mysql_query($query1_1);
	 $res2 = "select t.growth_speed as speed,i.age as age from info i, carbon c, tree_name t where i.age = c.age and i.tree_name = t.tid and i.aid = '".$row['id']."'";
	 
	 $res2_1 = "select t.growth_speed as speed,i.age as age from info i, carbon c, tree_name t where i.age = c.age and i.tree_name = t.tid and i.aid = '".$row['id']."'";
	  $carbon_query = mysql_query($res2);
	  $carbon_query_1 = mysql_query($res2_1);
	  
	  //echo $res2_1;

 	echo "<table border='1'  align='center'  cellpadding='2' cellspacing='2' style='font-family:Verdana; font-size:8pt; border-collapse: collapse; style='width:90%; margin:15px;  '>";

echo "<tr><td colspan='17' style='padding:10px;'>
	Survey Sheet Number : ".$row['survey_sheet_no']."<br>
	Ward Name : ".$result_ward['wvalue']."<br>
	Sub Ward Name : ".$result_sub['dvalue']."<br>
	Date : ".$row['current_date1']."<br>
	Property Name : ".$row['society_name']."<br>
	Sub Area : ".$row['sub_area']."<br>
	House Owner : ".$row['owner']."<br>";
	
	if($row['type'] == "Roadside"){
		echo "Length of Road : ".$row['plot_area']."<br>";
	}
	else{
		echo "Area of Property : ".$row['plot_area']."<br>";
	}
	
	echo "Type : ".$row['type']."<br>
	Surveyor Name : ".$result_surveyor['username']."<br>

	<td colspan='3'> <a href='phpsql_while.php?id=$row[id]' style='text-decoration:none;'>"."<input type='button' value='Download KML' name='kml' >  </a>
	
	<a href='phpsql_while.php?id=$row[id]' style='text-decoration:none;'>"."<input type='button' value='View Video/Panaromic View' name='kml' ></td>

</tr> <br> ";

	$sql_q_1="SELECT * FROM input_form WHERE id = '".$row['id']."'  ";
	//echo $sql_q_1;
	$rest_1=@mysql_query($sql_q_1);
	$row_1 =@mysql_fetch_object($rest_1);
	$plot_area_1 = trim($row_1->plot_area);
	
	$query_1= @mysql_fetch_array(mysql_query("select * from required_tree r, input_form i where r.measure = i.type and id = '".$row['id']."' "));
	
	//echo "select * from required_tree r, input_form i where r.measure = i.type and id = '".$row['id']."' ";
	$area_1 = $query_1['area'];
	//echo $area_1;
	$tree_1 = $query_1['tree'];
	//echo $tree_1;
	$ans_1 = (($plot_area_1)/($area_1));


	$sql2_1="select aid from info where aid = '".$row['id']."'";
	
$sql3_1="select count(i.tree_name) as count, t.tree_name as tree_name,t.scientific_name as scientific_name from info i,tree_name t where aid = '".$row['id']."'  and t.tid = i.tree_name group by tree_name";
	
	//echo $sql3_1;

	$sql4_1 = "select manual_tree as tree_name,count(manual_tree) as count from info where aid = '".$row['id']."' and tree_name = '' and manual_tree <> ''  group by manual_tree";
	
	//echo $sql4."<br>";
	
	$sql5_1 = "select manual_sci_tree as tree_name,count(manual_sci_tree) as count from info where aid = '".$row['id']."' and tree_name = '' and manual_sci_tree <> ''  group by manual_sci_tree";
	
	//echo $sql5."<br>";

	$result2_1 = mysql_query($sql2_1);
	$result3_1 = mysql_query($sql3_1);
	$result4_1 = mysql_query($sql4_1);
	$result5_1 = mysql_query($sql5_1);

	$num1 = @mysql_num_rows($result2_1);
	
	$deficit_trees_1 = $ans_1-$num1;
	
	$n1 = @mysql_num_rows($result3_1);
	$n2 = @mysql_num_rows($result4_1);
	$n3 = @mysql_num_rows($result5_1);
	
	$no_of_species = $n1+$n2+$n3;
	
	$native_query_1 = "select native from info i, tree_name t where aid = '".$row['id']."' and i.tree_name = t.tid and t.native = 'Native'";
	$native_result_1= mysql_query($native_query_1);
	$native_num_1 = mysql_num_rows($native_result_1);
	
	$exotic_query_1 = "select native from info i, tree_name t where aid = '".$row['id']."' and i.tree_name = t.tid and t.native = 'Exotic'";
	$exotic_result_1 = mysql_query($exotic_query_1);
	$exotic_num_1 = mysql_num_rows($exotic_result_1);
	
	
echo "<tr><td colspan = '20'> <br>";

echo "<table border='1' align='center' cellpadding='2' cellspacing='2'  style='font-family:Verdana; font-size:8pt; border-collapse: collapse; width:50%; margin-bottom:15px; '>";
	
	echo "<tr><th align ='left' >Name of the tree </th>
		<th>No of Trees</th>
	</tr>";
	while($a = mysql_fetch_array($result3_1))
	{
		
		echo "<tr><td>";
		if($a['tree_name'] != "--")
		{
			echo $a['tree_name']."</td><td> ".$a['count'];	
		}
		else
		{
			echo $a['scientific_name']."</td><td> ".$a['count'];
		}
		echo "</td></tr>";
	}
	while($a = mysql_fetch_array($result4_1))
	{
		
		echo "<tr><td>";
		echo $a['tree_name']."</td><td> ".$a['count'];
		echo "</td></tr>";
	}
	while($a = mysql_fetch_array($result5_1))
	{
		
		echo "<tr><td>";
		echo $a['tree_name']."(sci)</td><td> ".$a['count'];
		echo "</td></tr>";
	}
	$total_carbon = 0.0;
	while($row_1 = mysql_fetch_array($rest1_1))
	{
		$res_carbon_query_1 = mysql_fetch_array($carbon_query_1);
	  
		  if($res_carbon_query_1['speed'] != "")
		  {
	$res3_1 = "select `".$res_carbon_query_1['speed']."` from carbon where `age` = '" .$res_carbon_query_1['age']."'";
	  $carbon_1 = mysql_query($res3_1);
	  
	  //echo $res3_1;
		  
	  $res_carbon_1 = mysql_fetch_array($carbon_1);
		  }
		  
		  $total_carbon = $total_carbon+$res_carbon_1[$res_carbon_query_1['speed']];
		  
	}
	//echo "--".$total_carbon."<br>";
		echo "<tr><td>";
		echo "<b>Total Number of Trees:</b></td><td> <b>".$num1;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Deficit Trees:</b></td><td> <b>".round($deficit_trees_1);
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>No of Species Recorded:</b></td><td> <b>".$no_of_species;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Carbon Sequestration Potential of Trees(lbs per year) : </b></td><td> <b>".$total_carbon;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Number of Native Trees: </b></td><td> <b>".$native_num_1;
		echo "</b></td></tr>";
		
		echo "<tr><td>";
		echo "<b>Number of Exotic Trees: </b></td><td> <b>".$exotic_num_1;
		echo "</b></td></tr>";
		
	echo "</table> <br>";

echo "</td></tr>";

 echo "<tr>
<th style='width:10%;'>Sr. No.</th>

<th style='width:10%;'>Tree Name</th>

<th style='width:10%;'>Scientific Name</th>

<th style='width:10%;''>GBH (cm) </th>

<th style='width:10%;'> Height (ft) </th>

<th style='width:10%;'>Canopy Diameter (ft) </th>

<th style='width:10%;'>Age (yr)</th>

<th style='width:10%;'>Condition </th>

<th style='width:10%;'>Longitude </th>

<th style='width:10%;'>Latitude </th>

<th style='width:10%;'>Flowering Season</th>

<th style='width:10%;'>Flower Color</th>

<th style='width:10%;'>Fruiting Season</th>

<th style='width:10%;'>Native/Exotic</th>

<th style='width:10%;'>Growth Rate</th>

<th style='width:10%;'>Wild/Cultivated</th>

<th style='width:10%;'>Use</th>

<th style='width:10%;'>Time</th>

<th style='width:10%;'>Carbon Sequestration (lbs per year)</th>

<th style='width:10%;'>Images</th>


</tr>";



while($row = mysql_fetch_array($rest1))

  {
	  $sr++;
		$query_image = mysql_query("SELECT info.`aid`,`image_path`.`pid` , image_path.`img_path`,info.`tree_name` FROM info
								INNER JOIN `image_path` ON info.pid = image_path.pid WHERE info.`pid`='".$row['pid']."'");
								
		
																				
		$result_image = mysql_fetch_array($query_image);

		$time = explode("_",$row['current_time1']);
		$b = ($time[3] == "1")? "pm" : "am";
		$time = $time[0].":".$time[1].":".$time[2]." ".$b;
	  $query_tree = mysql_query("select * from tree_name where tid= '".$row['tree_name']."'");

	  $result_tree = mysql_fetch_array($query_tree);
	  
	 
	  
	  //echo "select t.growth_speed as speed from info i, carbon c, tree_name t where i.age = c.age and i.tree_name = t.tid and i.aid = '".$row['aid']."'";
	  
	 $res_carbon_query = mysql_fetch_array($carbon_query);
	  
		  if($res_carbon_query['speed'] != "")
		  {
		  $res3 = "select `".$res_carbon_query['speed']."` from carbon where `age` = '" .$res_carbon_query['age']."'";
	  $carbon = mysql_query($res3);
	  
	 // echo $res3;
		  
	  $res_carbon = mysql_fetch_array($carbon);
		  }
	//echo $c = $res_carbon[$res_carbon_query['speed']]."<br>";
	  
   echo "<tr>";

		echo "<td align ='left' style='width:10%;'>" . $sr . "</td>";
		
	  echo "<td align ='left' style='width:10%;'>" . $result_tree['tree_name'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $result_tree['scientific_name'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row['width'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row['height'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row['diameter_of_tree'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row['age'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row['con'] . "</td>";
	  
	  

	   echo "<td  ' style='width:10%;'>" . $row['lng'] . "</td>";	  

	   echo "<td  ' style='width:10%;'>" . $row['lat'] . "</td>";	  
	   
	   echo "<td align ='left' style='width:10%;'>" . $result_tree['flowering_season'] . "</td>";
	  
	  echo "<td align ='left' style='width:10%;'>" . $result_tree['flower_color'] . "</td>";
	
		echo "<td align ='left' style='width:10%;'>" . $result_tree['fruiting_season'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['native'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['growth_speed'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['wild_cultivated'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['use'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $time . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $res_carbon[$res_carbon_query['speed']] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . "<div align='left'><img src='$result_image[img_path]' style='height:80; width:80'></div></td>";
  echo "</tr>";

  }

  echo "</table>";

  echo "</td>";
	
	echo "</tr>";

  echo "</table> <br>";
}

 }
 else {echo "No Records to display";}
?>

</table>

<?php



}

?>





		

	<?php /*?><?php include("footer.php"); ?><?php */?>	

    

   </div>

    



    	

   </div> 



<!--<div id="footer">Copyright © 2012.Smart Survey All Rights Reserved.Website Designed & Developed by Kalpak Solutions</div>-->











</body>

</html>