title: how can i display values from table according to a column between two dates and time?
body: <p>I have two tables floattable(dateandtime,mitm,tagindex,value,status,marker) and tagtable(tagname,tagindex,tagtype,tagdatatype).i want to display output as</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form  method="POST" action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']);?&gt;"&gt;
  &lt;p&gt;REPORT&lt;/p&gt;
  Select AI Type:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
  &lt;select name="AI-Types" id="AI-Tpes"&gt;
  &lt;option value="select"&gt;--Select--&lt;/option&gt;
  &lt;option value="DTP4"&gt;DTP4&lt;/option&gt;&lt;option value="FT1"&gt;FT1&lt;/option&gt;&lt;option value="FT2"&gt;FT2&lt;/option&gt;&lt;option value="FT3"&gt;FT3&lt;/option&gt;&lt;option value="LT1"&gt;LT1&lt;/option&gt;&lt;option value="LT2"&gt;LT2&lt;/option&gt;&lt;option value="PT1"&gt;PT1&lt;/option&gt;&lt;option value="PT2"&gt;PT2&lt;/option&gt;
  &lt;option value="PT3"&gt;PT3&lt;/option&gt;&lt;option value="TE1"&gt;TE1&lt;/option&gt;&lt;option value="TE2"&gt;TE2&lt;/option&gt;&lt;option value="TE4"&gt;TE4&lt;/option&gt;&lt;option value="VFD"&gt;VFD&lt;/option&gt;&lt;option value="XT3"&gt;XT3&lt;/option&gt;&lt;option value="XT4"&gt;XT4&lt;/option&gt;&lt;option value="PT2"&gt;PT2&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;&lt;br&gt;
  &lt;b&gt;From Date:&lt;/b&gt;
  &lt;input type="date" id="fromdate" name="fromdate" value="&lt;?php if(isset($fromdate)) echo $fromdate;?&gt;" size="20" /&gt;
  &lt;b&gt;To Date:&lt;/b&gt;
  &lt;input type="date" id="todate"   name="todate"   value="&lt;?php if(isset($todate)) echo $todate;?&gt;"     size="20"/&gt;&lt;br&gt;&lt;br&gt;
  &lt;b&gt;From Time:&lt;/b&gt;
  &lt;input type="time" id="fromtime" name="fromtime" value="&lt;?php  if(isset($fromtime))echo $fromtime;?&gt;" size="30" /&gt;
  &lt;b&gt;To Time:&lt;/b&gt;
  &lt;input type="time" id="totime"   name="totime"   value="&lt;?php if(isset($totime)) echo $totime;?&gt;"     size="30"/&gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="submit" id="submit" name="submit"   value="GENERATE"/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="reset" id="reset" name="reset" value="RESET"/&gt;&lt;br&gt;&lt;br&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php
    
   if(isset($_POST["submit"]))
   {
      $fromdate=$_POST['fromdate'];
   $todate=$_POST['todate'];
   $fromtime=$_POST['fromtime'];
   $totime=$_POST['totime']; 
   if(!$fromdate || !$todate ||!$fromtime||!$totime)
   echo " please provide all the fields"; 
             global $conn;    
             // Create connection
                $conn = mysqli_connect('localhost', 'root', '','test');
             // Check connection
                 if (!$conn) 
               {
                   die("Connection failed: " . mysqli_connect_error());
                  }
  
                  $sql ="SELECT * FROM floattable WHERE TagIndex=$tagindex AND (DateAndTime between '$fromdate .'  '. $fromtime' AND '$todate .'  '. $totime') ORDER BY DateAndTime ASC;";
  
                  $result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
          function fill_data($tagindex)
              
           try{
       function fill_data($tagindex)
       {//for IP
       if  (($tagindex=0)||($tagindex=1)||($tagindex=2)||($tagindex=3)||($tagindex=4)||($tagindex=5)||($tagindex=6)||($tagindex=7)||($tagindex=8)||($tagindex=10)||($tagindex=11)||($tagindex=12)||($tagindex=13)||($tagindex=14)||($tagindex=14)||($tagindex=15)||
        ($tagindex=16)||($tagindex=17)||($tagindex=18)||($tagindex=19)||($tagindex=20)||($tagindex=21)||($tagindex=22)||($tagindex=23)||($tagindex=24)||($tagindex=25)||($tagindex=26)||($tagindex=27)||($tagindex=28)||($tagindex=29)||($tagindex=30)||($tagindex=31)||($tagindex=32)||
        ($tagindex=33)||($tagindex=34)||($tagindex=35)||($tagindex=36)||($tagindex=37)||($tagindex=38)||($tagindex=39)||($tagindex=40)||($tagindex=41)||($tagindex=42)||($tagindex=43)||($tagindex=44)||($tagindex=45)||($tagindex=46)||($tagindex=47)||($tagindex=48)||($tagindex=49))
        {
        // to display output
        echo "&lt;table border='1' cellspacing='3' align='centre'&gt;
          &lt;tr&gt;
          &lt;th&gt;DateAndTime&lt;/th&gt;
          &lt;th&gt;Millitm&lt;/th&gt;
          &lt;th&gt;TagIndex&lt;/th&gt;
          &lt;th&gt;Value&lt;/th&gt;
          &lt;th&gt;Status&lt;/th&gt;
          &lt;th&gt;Market&lt;/th&gt;
          &lt;/tr&gt;";
  
           while ($row = mysqli_fetch_array($result)) 
         {
          echo " &lt;tr&gt;
          &lt;td&gt;".$row['DateAndTime']."&lt;/td&gt;
          &lt;td&gt;".$row['Millitm']."&lt;/td&gt;
           &lt;td&gt;".$row['TagIndex']."&lt;/td&gt;
            &lt;td&gt;".$row['Val']."&lt;/td&gt;
          &lt;td&gt;".$row['Status']."&lt;/td&gt;
           &lt;td&gt;".$row['Marker']."&lt;/td&gt;
          &lt;/tr&gt;";
         }
                   echo "&lt;/table&gt;";
             }
                
           }
     }
       catch (Exception $e)
       {
        echo $e-&gt;getmessage();
        exit(1);
       }
       
          if(isset($_POST['submit']))
       { 
            $selected_val = $_POST['AI-Types'];
       try{
        
         $currentSheet = "DTP4";
                          fill_data(0);
                          fill_data(1);
                          fill_data(2);
                        
           $currentSheet = "FT1";
                          fill_data(3);
                         
           $currentSheet = "FT2";
                          fill_data(4);
        
        $currentSheet = "FT3";
                          fill_data(5);
        fill_data(6);
  
                          $currentSheet = "LT1";
                          fill_data(7);
                         
          $currentSheet = "LT2";
                          fill_data(8);
        fill_data(9);
        
        $currentSheet = "PT1";
                          fill_data(10);
  
        $currentSheet = "PT2";
                          fill_data(11);
        fill_data(12);
        fill_data(13);
        fill_data(14);
        
        $currentSheet = "PT3";
                          fill_data(15);
        fill_data(16);
        
        $currentSheet = "TE1";
                          fill_data(17);
        fill_data(18);
        fill_data(19);
        
        $currentSheet = "TE2";
                          fill_data(20);
        fill_data(21);
        fill_data(22);
        fill_data(23);
        
        $currentSheet = "TE4";
                          fill_data(24);
        fill_data(25);
        fill_data(26);
        fill_data(27);
        fill_data(28);
        fill_data(29);
        
                          $currentSheet = "VFD";
                          fill_data(30);
        fill_data(31);
        fill_data(32);
        fill_data(33);
        fill_data(34);
        fill_data(35);
        fill_data(36);
        
        $currentSheet = "XT3";
                          fill_data(37);
        fill_data(38);
  
        $currentSheet = "XT4";
                          fill_data(39);
        $currentSheet = "PT2";
                          fill_data(40);
        
         
         }
              catch (Exception $e)
             {
          echo $e-&gt;getmessage();
             exit(1);
          }
                      }
     mysqli_close($conn);
     
     
    }   
   
   
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>but the issue is that in floattable tagindexes are in 0-81 indexes and I want to get all records which are having their tagindex eg. 1 but conditions are like I have to sort data according to tagnames from tag table eg.DTP4_xxxx/IP(its a tagname).I have written a method fill_data($tagindex).
  I am new at PHP.plz help me.Thanks in advance</p>