Guest User

Untitled

a guest
Oct 17th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. pid, posterid, content
  2. 1 , 26 , blabla
  3. 2 , 8 , sec balnla
  4. 3 , 9 , lollll
  5. 4 , 26 , orddddd
  6. 5 , 10 , sssssdsd
  7. ...
  8.  
  9. function getComments($poster){
  10. $sql = "SELECT * FROM table WHERE posterid = $poster"
  11. $smt = $db->query($sql);
  12. $total = $smt->rowCount();
  13.  
  14. $result = $db->prepare($sql . " ORDER BY pid DESC $limit");
  15. $result->execute();
  16. while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
  17. $Comments[] = $row;
  18. }
  19. return [
  20. 'comments' => $Comments,
  21. 'total' => $total
  22. ];
  23. }
  24.  
  25. $poster = 26;
  26. $pid = 18;
  27. $posttperpage = 10;
  28.  
  29. public function getPostPage($pid, $poster, $posttperpage)
  30. {
  31. $page = '';
  32.  
  33. $totlaPosts = getComments($poster)['total']; //70
  34.  
  35. $pages = $totlaPosts / $posttperpage; //7
  36.  
  37. for($i=0, $i<$totlaPosts, $i--)
  38. {
  39. // ?????
  40. // i confuzed no idead what can i do :(
  41.  
  42. }
  43. return $page; //it must be 2
  44. }
  45.  
  46. $k = 1;
  47. for($i=0, $i<$pid; $i += $posttperpage){
  48. $page = $k;
  49. $k +=1;
  50. }
  51.  
  52. //after loop $page now contains what page the post is on.
Add Comment
Please, Sign In to add comment