How to display data based on post date similar to a timeline using PHP MYSQL -


please me i'm in great problem. want display posts(articles) under respective posting date.

for example,

november 05 * post 1 * post 2 * post 3  november 04 * post 1 * post 2 

i have written php code it's repeating dates , values twice, like:

november 05 * post 1 * post 2 * post 3 november 05 * post 1 * post 2 * post 3  november 04 * post 1 * post 2  november 04 * post 1 * post 2 

please me!

here's code:

      <?php     include("db.php");     include("function.php");     $result=mysqli_query($con,"select distinct post_submitted_on posts order id desc");     while($row=mysqli_fetch_array($result)){     $datetime=$row['post_submitted_on']; //2016-11-05 23:10:45     $date=date("d",strtotime($datetime)); //05     $month=date("f",strtotime($datetime)); //november     $final_date=date("y-m-d",strtotime($datetime)); //2016-11-05   ?>       <h4 class="date">         <i style="vertical-align: baseline;" class="fa fa-calendar-o date"></i> <b class="date">today, <?php echo strtoupper($month);?> <?php echo ordinal("$date");?></b> <!-- prints today, november 05 -->       </h4>       <?php         $sql=mysqli_query($con,"select distinct * posts post_date='$final_date' order id desc"); //selecting posts based on current date , load past entries based on past date         while($r=mysqli_fetch_array($sql)){       ?>       <table width="100%" class="hidden-sm hidden-xs">         <tr>           <td>             <?php echo $r['title'];?>             <?php echo $r['url'];?>           </td>         </tr>       </table>     <?php } ?>   <?php } ?> 

i'll post community wiki since mentioned myself in comments , being solution question.

  • add group col query, since using distinct doesn't job.

consult following q&a on stack type of behaviour:


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -