<?php 
include("database.php");
if($_GET['q']!="")
{	
	$q=$_GET["q"];
	$sql1= @mysql_fetch_array(mysql_query("select * from master_ward_drop where did='$q'"));
	$sql="SELECT * FROM input_form WHERE ward= '$q'  ";
	//echo $sql;
	//echo "SELECT * FROM input_form WHERE ward= '".$sql1['dvalue']."'  ";
	$rest=@mysql_query($sql);
	$query= @mysql_fetch_array(mysql_query("select * from required_tree"));
	//echo "select * from required_tree";
	$area = $query['area'];
	$tree = $query['tree'];
	//echo $area;
	//echo $tree;
?>
<table border="1" cellpadding="2" cellspacing="2" width="100%" align="center" bordercolor="#bcd5e7" >
	   
	 <tr>
    	 
        <td align="left" ><font class="font4"><b>View</font></td>
		<td align="left"><font class="font4"><b>Ward Office</font></td>
        <td align="left"><font class="font4"><b>Ward</font></td>
        <td align="left"><font class="font4"><b>Date</font></td>
        <td align="left"><font class="font4"><b>Society Name</font></td>
        <td align="left"><font class="font4"><b>Number Of Trees</font>
        <td align="left"><font class="font4"><b>Expected Number of Trees</font>
        </td>
     </tr>
     <?php
   while ($row =@mysql_fetch_object($rest)) 
	{
	$query1="select * from info where aid='".$row->id."'";
	//echo "select * from info where aid='".$row->id."'";
	$rest1=@mysql_query($query1);
 	$num = @mysql_num_rows($rest1);
 	$plot_area = trim($row->plot_area);
	//echo $plot_area;
 	$ans = ((($plot_area)/($area))*($tree));
	
	$ans1 = $ans-$num;
	
	$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);
 	if($num<$ans)
 	{
	echo "<tr>";
	
	echo "<td align='left' ><a href='view_records.php?id=$row->id'><font class='font4'>"."<img src='images/view.png' border='0'>"."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$result_ward['wvalue']."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$result_sub['dvalue']."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$row->current_date1."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$row->society_name."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".$num."</font></div></td>";
	echo "<td  align='left'>"."<div align='left'>"."<font class='font4'>".round($ans1)."</font></div></td>";
	echo "</td>";
	}
	}
?>

</table>
    
<?php 
}	else
	{
		echo "No Records To Display";
	}
?>
<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>