Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pid, posterid, content
- 1 , 26 , blabla
- 2 , 8 , sec balnla
- 3 , 9 , lollll
- 4 , 26 , orddddd
- 5 , 10 , sssssdsd
- ...
- function getComments($poster){
- $sql = "SELECT * FROM table WHERE posterid = $poster"
- $smt = $db->query($sql);
- $total = $smt->rowCount();
- $result = $db->prepare($sql . " ORDER BY pid DESC $limit");
- $result->execute();
- while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
- $Comments[] = $row;
- }
- return [
- 'comments' => $Comments,
- 'total' => $total
- ];
- }
- $poster = 26;
- $pid = 18;
- $posttperpage = 10;
- public function getPostPage($pid, $poster, $posttperpage)
- {
- $page = '';
- $totlaPosts = getComments($poster)['total']; //70
- $pages = $totlaPosts / $posttperpage; //7
- for($i=0, $i<$totlaPosts, $i--)
- {
- // ?????
- // i confuzed no idead what can i do :(
- }
- return $page; //it must be 2
- }
- $k = 1;
- for($i=0, $i<$pid; $i += $posttperpage){
- $page = $k;
- $k +=1;
- }
- //after loop $page now contains what page the post is on.
Add Comment
Please, Sign In to add comment