Sir I have these codes

<?php
   session_start();
   if(!isset($_SESSION['user'])) 
   {
     header("location: admin/login.php");
   }
   include_once("includes/connectsql.php");

   $date1=date('Y-m-d');
   $t_date1=isset($_POST['t_date1'])?$_POST['t_date1']:$date1;
   $t_date1=date('Y-m-d',strtotime($t_date1));

   //-----------------------------------------------------
   // find
   if(isset($_POST['btn_find']))
   {

   $acc_code1='2310001';
   $mybalance=0;
   $mydrcr='';

   $query = "select vou_no,acc_code,acc_name,dr_amount,cr_amount,qty,circle
   from crsalp where date='".$t_date1."' and (SUBSTRING(acc_code,1,2)='32' or SUBSTRING(acc_code,1,2)='33')
   order by vou_no,acc_code";
   }

   ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<head>
   <title>Sales Journal</title>
   <style type="text/css">
      .container{
      margin:0 auto;
      width:40%;
      border:1px solid gray;
      padding-top:40px;
      margin-top:40px;
      }
   </style>
</head>
<body>
   <div class="container">
      <form name="form1" action="<?php $_PHP_SELF;?>" method="post">
         <center>
            <label> Date </label>
            <input type="text"  size="9" name="t_date1"
               id="datepicker-13" value="<?php echo date('d-m-Y', strtotime($t_date1));?>" required="required"/>
            <input type="submit"  name="button1" value="Find"/>
         </center>
         <br />
         <table width='80%' align="center">
            <thead align="center">
               <tr>
                  <td width="8%">Vou. #</td>
                  <td width="8%">Code</td>
                  <td width="8%">Qty.</td>
                  <td width="10%">Amount</td>
               </tr>
            </thead>
            <?php
               $query = "select vou_no,acc_code,acc_name,dr_amount,cr_amount,qty,circle
               from crsalp
               where date='".$t_date1."' and (SUBSTRING(acc_code,1,2)='32' or SUBSTRING(acc_code,1,2)='33')
               and qty>0
               order by vou_no,acc_code";

               $result = sqlsrv_query($con,$query) or die ("Error". sqlsrv_errors($con)) ;  
               $row_count = sqlsrv_num_rows($result);

               while($res = sqlsrv_fetch_array($result)) {
               echo "<tr>";
               echo "<td align='center'>".($res['vou_no'])."</td>"; 
               echo "<td align='center'>".substr($res['acc_code'],0,4)."-".substr($res['acc_code'],4,7)."</td>";
                    $partycode=($res['acc_code']);
               echo "<td align='center'>".($res['qty'] != 0 ? number_format($res['qty']):'')."</td>";
               echo "<td style='color:red;' align='right'>".($res['cr_amount'] != 0 ? number_format($res['cr_amount']):'')."</td>"; 
               echo "</tr>";
               }
                ?>
         </table>
      </form>
   </div>
</body>
</html>

When I run form then codes work fine, no error, showing this proper data
Untitled.png

When I select a NEW data then every time I have to press FIND button for page refresh.

Is it possible to get rid of submit button?
I mean when I select new date then data must appear in table.

Please help

Member Avatar for diafol

You can use a datepicker and set it to run the script on change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.