Harman_2 0 Newbie Poster

In this code I am getting posts from database in table, table displays posts in three columns, now I want to add some jQuery to limit the number of rows and add a button which on clicking appends few rows to table I am not a professional programmer may be something like slice should be used to limit number of rows.

$sql = "SELECT * FROM posts";
$query = $db->prepare($sql);
$query->execute();

<table>
 <tr> 
 <?php do { //horizontal looper?>
 <td> 
 <div>id</div> 
 <div>title</div>
  <div>body</div>
  <div>date</div>
  </td>
  <?php
 $row = $query->fetch(PDO::FETCH_ASSOC);
 if (!isset($nested_List)) {
 $nested_List= 1;
 }
 if (isset($row) && is_array($row) && $nested_List++%3==0) {
 echo "</tr><tr>";
 }
 } while ($row); //end horizontal looper 
?> 
</table>
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.