Advertisement
michaelyuen

Untitled

May 17th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.     </head>
  5.     <body>
  6.         <div id="post-wrapper">
  7.             <?php include "post.php"; ?>
  8.         </div>
  9.     </body>
  10. </html>
  11.  
  12. <script>
  13.     $(document).ready(function (){
  14.         setInterval(function(){
  15.             $('#post-wrapper).load("post.php");
  16.         },2000);
  17.     });
  18. </script>
  19.  
  20. #############
  21. post.php
  22. <?php
  23. // your query
  24. WHILE ($row = $result->fetch_assoc()) {
  25.     $rows[] = $row;
  26. }
  27. ?>
  28. <?php foreach ($rows as $row): ?>
  29.             <div class="post" id="<?= $row['postid']; ?>">
  30.                 <div class="content">
  31.                     <div class="content-image"><?= $row['postimage']; ?></div>
  32.                     <div class="content-text"><?= $row['content']; ?></div>
  33.                 </div>
  34.                 <div class="likes">
  35.                     <span><?= $row['likes']; ?></span>
  36.                 </div>
  37.             </div>
  38. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement