<?php include("../../include/dbconnect.php"); 
// Get all _POST VALUES HERE..
  foreach($_POST as $p=>$t)
  {
     $_POST[$p] = trim($t);
  }

  $mydate = $_POST['record'];

  
  ?>
<body background=blater01.gif  topmargin=0>
<center>
<h2><font face="Arial, Helvetica, sans-serif"><b>View Trading Invoices</font></h2>
<font face="Arial, Helvetica, sans-serif"></b>

<?php

$aresult = mysqli_query($conn,"select distinct account_year from company ");
$arow = mysqli_fetch_row($aresult);
$account_year = $arow[0];

// Pull all the data from date master & populate it

$stQuery = mysqli_query($conn,"select  distinct trading.record, trading.invdate, trading.invno, buy.name  from trading, buy where trading.bcode=buy.bcode and trading.prodcode='TOTAL' and account_year = '$account_year' order by trading.invno desc") or die(mysqli_error());
?>
</font>
<form name='myForm01' method='POST' action="editview.php?record=<?echo($record);?>">
  <font face="Arial, Helvetica, sans-serif">
<SELECT  name='record' onChange="javascript:submit();">
  
  <?
     echo "<option  selected value=\" 0\"> Select date";
    while($row = mysqli_fetch_row($stQuery))
    {

			$temp1 = 'Inv No : '.$row[2].'&nbsp;Dt : &nbsp;'.british($row[1]).'&nbsp;Name :&nbsp;'.$row[3];

        $temp = substr($row[1],8,2).'-'.substr($row[1],5,2).'-'.substr($row[1],0,4);
        if(isset($mydate) && preg_match("/" . preg_quote($mydate", '/') . "/", $row[0]))
	    {
            echo "<option selected value=\"$row[0]\">$temp1";
       }
       else{
           echo "<option value=\"$row[0]\">$temp1";
       }
		
    }
?>
</SELECT>
</td>
</tr>
  </font>
</form>



                                                                             
</body>


