
<?php include("../../include/dbconnect.php");


// Get all _POST VALUES HERE..

  foreach($_POST as $p=>$t)
  {
     $_POST[$p] = trim($t);
  }

  $myArea = $_POST['Area'];


// Pull all the data from Area master & populate it
?>
<table align="center" width=590>
      <tr > 
        
<td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Select 
  Area &nbsp;</font></b></font></td>
<td>

<?
$stQuery = mysqli_query($conn,"select distinct city from buy where city != '' order by city");

?>
<form name='myForm01' method='POST' action='<?=$_SERVER['PHP_SELF']?>'>
  <select name='Area' onChange="javascript:submit();">
    <?
     echo "<option selected value=\" 0\"> Select Area";
    while($row = mysqli_fetch_row($stQuery))
    {


        if(isset($myArea) && preg_match("/" . preg_quote($myArea", '/') . "/", $row[0]))
	    {
            echo "<option selected value=\"$row[0]\">$row[0]";
        }
        else{
            echo "<option value=\"$row[0]\">$row[0]";
        }
    }
?>
  </select>
</form>
</td> </tr>
    <?

// Pull all Customers from Customer  based on Selected Area id and populate it.


    $sBuyQuery = mysqli_query($conn,"select name,address1,address2,city,state,pin,std,telno,email,contact,cst,tin FROM buy WHERE (city ='$myArea') order by name ");


// This form contain a hidden field AreaID which can be later used in next  page..
?><form name='myForm02' method='POST' action='entry.php' >
    <?

while ($row = mysqli_fetch_row($sBuyQuery))
	{
	?>
   <table width="865" border="0">
      <tr>
        <td width="425"><b><font color="#990000"><? echo($row[0]);?></b></font></td><td width="430">Contact:<font color="#990099"><? echo($row[9]);?> </td>
      </tr>
      <tr>
        <td ><? echo($row[1]);?></td>
      </tr>
      <tr>
        <td><? echo($row[2]);?></td>
      </tr>
      <tr>
        <td><? echo($row[3]);?></td><td> CST:&nbsp;<? echo($row[10]);?></td>
      </tr>
      <tr>
        <td><? echo($row[4]);?></td><td> TIN:&nbsp;<? echo($row[11]);?></td>
      </tr>
      <tr>
        <td><? echo($row[5]);?></td>
      </tr>
      <tr>
        <td bgcolor="#6633FF">Tel:<? echo($row[6].'-'.$row[7]);?></td>
      </tr>
	        <tr>
        <td>Email:<? echo($row[8]);?></td>
      </tr>	 
	  
	  
      </tr>
	        <tr>
        <td>&nbsp;</td>
      </tr>	 	 
	  	  
      </tr>
	        <tr>
        <td>&nbsp;</td>
      </tr>	 
	    
    </table>	
	<?
	
	}


?>
<br><br><font size=1><center><a href= "index.html">Return to index page</a></center></font>