fetching data according date in php and mysql
<p><a href="http://i.stack.imgur.com/t617g.png" rel="nofollow">enter image description here</a></p>

<p>I am working on stock project.While I am fetching data date wise ,all data is displaying.Like i am searching 23.12.2015  ,it is fetching both records(item in 300 and 200),while i need only last record on particular date like here only second record(item in 200).</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&lt;='$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
</code></pre>