How to fetch previous date data in php mysql
<p><img src="https://i.stack.imgur.com/i6DCs.png" alt="enter image description here"></p>

<p>I am working on stock project in PHP.Currently while searching according date it is showing data according searching date which is good.But those date which is not avail in database ,it is showing blank,while i need prevous date data.(Like if i enter 25.12.2015,in the result it should show previous date data like 23.12.2015 in this case.)</p>

<p>my html code is:</p>

<pre><code>&lt;form action="dateview.php" method="post"&gt;
     &lt;table width="60%" border="2" bordercolor="green"&gt;
     &lt;tr&gt;
     &lt;td&gt;DATE&lt;/td&gt;
     &lt;td&gt;
         &lt;input type="date" name="date"&gt;
     &lt;/td&gt;
     &lt;td colspan="2"&gt;
         &lt;center&gt;&lt;input type="submit" value="search"/&gt;&lt;/center&gt;
     &lt;/td&gt;
     &lt;/table&gt;   
&lt;/form&gt; 
</code></pre>

<p>my php code is:</p>

<pre><code>&lt;?php
      if($qw="select * from details where date='$date'"){
      $qq = mysqli_query($con,$qw);
      while($r=mysqli_fetch_array($qq,MYSQLI_ASSOC))
      {
        ?&gt;
        &lt;tr&gt;
        &lt;td&gt;&lt;?php echo $r['itemname']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $r['deposit']; ?&gt;&lt;/td&gt;&lt;td&gt;&lt;?php echo $r['withdraw']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $r['total']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $r['approvedby']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $r['receivedby']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $r['givenby']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $r['receivedto']; ?&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;?php } ?&gt;
</code></pre>