title: Is there a way i can implement a "load more" code into my original code?
body: <p>Well i'm trying to make a website as you can see, and i'm having difficulty with the "LOAD MORE" button, what i in-vision is that whenever someone clicks this button it would go through preferably a php code that tells the database to load in 5 more posts.</p>
  
  <h2>show_posts.php</h2>
  
  <pre><code>&lt;?php
  
      $query = $con-&gt;query("SELECT * FROM `posts` ORDER BY `id` DESC LIMIT 5");
  
      if( isset( $_POST['load'] ) ){
          //code goes here
      }
  
      while($result = mysqli_fetch_assoc($query)){
          // if video is empty then echo this line
          if($result["video"] == ""){
              $account_assoc = $result["account_assoc"];
  
              $result2 = mysqli_fetch_assoc($con-&gt;query("SELECT * FROM `Accounts` WHERE username='$account_assoc' OR email='$account_assoc'"));
  
              if($result2["username"] == ""){
                  $identifier = $result2["firstname"];
              }else{
                  $identifier = $result2["username"];
              }
  
              if($result2['image'] == ""){
                  $image = "http://jnvbaghmara.nic.in/images/staff/Blank.png";
              }else{
                  $image = 'data:image/jpeg;base64,'.base64_encode($result2['image']);
              }
  
              if($result['dislikes'] &gt; 1){
                  $dislike = "&lt;label style='color: red;'&gt;".format_num($result['dislikes'])."&lt;/label&gt; Dislikes";
              }else{
                  $dislike = "&lt;label style='color: red;'&gt;".format_num($result['dislikes'])."&lt;/label&gt; Dislike";
              }
  
              if($result['likes'] &gt; 1){
                  $like = "&lt;label style='color: #0096f3;'&gt;".format_num($result['likes'])."&lt;/label&gt; likes";
              }else{
                  $like = "&lt;label style='color: #0096f3;'&gt;".format_num($result['likes'])."&lt;/label&gt; like";
              }
  
              echo '&lt;li&gt;
              &lt;h4&gt;&lt;img src="'.$image.'"/&gt; &lt;label&gt;'.$identifier.'&lt;/label&gt;&lt;/h4&gt;
              &lt;div class="all-content"&gt;
              &lt;label style="color: #777;"&gt; '.$like.' &lt;/label&gt;&lt;label style="color: #777;"&gt; | '.$dislike.'&lt;/label&gt;&lt;label style="color: #777;"&gt; | 2 comment&lt;/label&gt;
              &lt;p&gt;'.$result["text"].'&lt;/p&gt;
              &lt;/div&gt;&lt;/li&gt;';
          }
          // if video is not empty then echo this line
          elseif($result["video"] != ""){
              $account_assoc = $result["account_assoc"];
  
              $result2 = mysqli_fetch_assoc($con-&gt;query("SELECT * FROM `Accounts` WHERE username='$account_assoc' OR email='$account_assoc'"));
  
              if($result2["username"] == ""){
                  $identifier = $result2["firstname"];
              }else{
                  $identifier = $result2["username"];
              }
  
              if($result2['image'] == ""){
                  $image = "http://jnvbaghmara.nic.in/images/staff/Blank.png";
              }else{
                  $image = 'data:image/jpeg;base64,'.base64_encode($result2['image']);
              }
  
              if($result['dislikes'] &gt; 1){
                  $dislike = "&lt;label style='color: red;'&gt;".format_num($result['dislikes'])."&lt;/label&gt; Dislikes";
              }else{
                  $dislike = "&lt;label style='color: red;'&gt;".format_num($result['dislikes'])."&lt;/label&gt; Dislike";
              }
  
              if($result['likes'] &gt; 1){
                  $like = "&lt;label style='color: #0096f3;'&gt;".format_num($result['likes'])."&lt;/label&gt; likes";
              }else{
                  $like = "&lt;label style='color: #0096f3;'&gt;".format_num($result['likes'])."&lt;/label&gt; like";
              }
  
              echo '&lt;li&gt;
              &lt;h4&gt;&lt;img src="'.$image.'"/&gt; &lt;label&gt;'.$identifier.'&lt;/label&gt;&lt;/h4&gt;
              &lt;div class="all-content"&gt;
              &lt;iframe width="90%" height="90%" src="https://www.youtube.com/embed/'.$result["video"].'" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
              &lt;p&gt;'.$result["text"].'&lt;/p&gt;
              &lt;label style="color: #777;"&gt; '.$like.' &lt;/label&gt;&lt;label style="color: #777;"&gt; | '.$dislike.'&lt;/label&gt;&lt;label style="color: #777;"&gt; | 2 comment&lt;/label&gt;
              &lt;/div&gt;
              &lt;/li&gt;';
          }
      }
  
      echo '&lt;li&gt;
      &lt;div class="all-content"&gt;
      &lt;form method="post" action="#"&gt;
      &lt;input type="submit" name="load" value="LOAD MORE..." class="load_more_button"/&gt;
      &lt;/form&gt;
      &lt;/div&gt;
      &lt;/li&gt;';
  ?&gt;
  </code></pre>
  
  <h2>profile.php</h2>
  
  <pre><code>&lt;?php include('include/header.php'); ?&gt;
  &lt;?php
      $error = "";
  
      if(isset($_POST['post'])){          
          $video = substr($_POST["video"], 17);
          $text = $_POST['paragraph'];
          $account_assoc = "";
  
          if($_SESSION['username'] != ""){
              $account_assoc = $_SESSION['username'];
          }elseif($_SESSION['email'] != ""){
              $account_assoc = $_SESSION['email'];
          }
  
          $con-&gt;query("INSERT INTO `posts` (`id`, `image`, `video`, `text`, `account_assoc`, `likes`, `dislikes`) VALUES ('', '$image', '$video', '$text', '$account_assoc', '0', '0')");
  
      }
  
  ?&gt;
  &lt;div class="content"&gt;
      &lt;div class="actual_content"&gt;
          &lt;div class="right-content"&gt;
              &lt;div style="padding: 10px;"&gt;
                  &lt;div id="post"&gt;
                      &lt;h3&gt;Latest News&lt;/h3&gt;
                      &lt;ul class="inner-post"&gt;
                          &lt;?php
  
                          $sql = $con-&gt;query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 5");
  
                          function myTruncate($string, $limit, $break=" ", $pad="..."){
                          if(strlen($string) &lt;= $limit){
                          return $string;
                          }
  
                          $string = substr($string, 0, $limit);
                          if(false !== ($breakpoint = strrpos($string, $break))) {
                          $string = substr($string, 0, $breakpoint);
                          }
  
                          return $string . $pad;
                          }
  
                          while($result = mysqli_fetch_array($sql)){
                          $header = $result['header'];
                          $statement = $result['statement'];
                          $image = $result['image'];
                          $shortdesc = myTruncate($statement, 300);
  
                          echo '&lt;li&gt;&lt;h5&gt;&lt;img src="#" /&gt;&lt;label&gt;'.$header.'&lt;/label&gt;&lt;/h5&gt;&lt;p&gt;'.$shortdesc.'&lt;/p&gt;&lt;/li&gt;';
                          }
                          ?&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="left-content"&gt;
              &lt;div class="post-holder" width="70%" style="padding: 10px;"&gt;
                  &lt;form class="post" method="post" action="#"&gt;
                      &lt;textarea name="paragraph" placeholder="Hey there! Share a game highlight with a photo or video... &lt;?php echo $error; ?&gt;" maxlength="250"&gt;&lt;/textarea&gt;
                      &lt;input type="submit" name="post" class="button_post" value="POST" /&gt;
                      &lt;label class="video"&gt;&lt;input type="text" name="video" placeholder="Use a YouTube link in order to post video..."/&gt;&lt;/label&gt;&lt;br /&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div class="new-posts" style="padding: 10px;"&gt;
                  &lt;ul&gt;
                      &lt;?php include('show_posts.php')?&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="footer"&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Also if there is anyway to make my code simpler, then i'm open to suggestions.</p>
  
  <p>*I want the code to be php because i understand php more than i do js, jquery etc.</p>