Advertisement
michaelyuen

Untitled

May 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. <?php
  2. $rows = $this->getPosts();
  3.  
  4. foreach ($rows as $row) {
  5.     $row->likes = $this->getLikes($row->id_post);
  6. }
  7. // now you have everything in one object
  8. ?>
  9.  
  10.  
  11.  
  12. <?php foreach ($rows as $row): ?>
  13. <div class="POST">
  14. <?php for($i=0; $i<=3; $i++): ?>
  15. <?= $row->likes[$i]->firstname; ?>
  16. // this will loop 3 user likes
  17. <?php endfor; ?>
  18. </div>
  19. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement