function page_archive($page_num) { global $posts, $title; $pagination = new Pagination(); $p = $pagination->calculate_pages(count($posts), POST_BY_PAGE, $page_num); $posts = array_slice($posts, ($page_num - 1) * POST_BY_PAGE, POST_BY_PAGE); if ($page_num > 1) { $title = sprintf(TITLE_FORMAT_ARCHIVE, $page_num); } include __DIR__ . '/../pages/home.php'; }
/** * getting array of all orders * @return array $orders */ function get_all_orders(&$pag_info) { $orders = array(); $total = db_query_to_row("SELECT COUNT(id) as total FROM orders WHERE status > 0"); if ($total) { $count = $total['total']; $p = new Pagination(); $page = isset($_GET['page']) ? abs((int) $_GET['page']) : 1; $pag_info = $p->calculate_pages($count, 10, $page); $orders = db_query_to_array("SELECT o.*, u.first_name, u.last_name FROM orders as o LEFT JOIN users as u ON u.id = o.user_id WHERE o.status > 0 ORDER BY o.id DESC " . $pag_info['limit']); if ($orders) { foreach ($orders as &$order) { $week_numbers = get_order_weeks($order['id']); $order['week_number'] = ''; foreach ($week_numbers as $week) { $order['week_number'] = $week; break; } } } } return $orders; }
//Let's setup our pagination $pagies = new Pagination(); $pagies->addToLink('?page=' . $pageName . '&id=' . $ArticleID); $perPage = 10; //count the total records $res = $DB->prepare("SELECT COUNT(*) FROM `article_comments` WHERE `article` = :id;"); $res->bindParam(':id', $ArticleID, PDO::PARAM_INT); $res->execute(); $count_row = $res->fetch(PDO::FETCH_NUM); $count = $count_row[0]; unset($count_row); unset($res); //Pull the comments if ($count > 0) { //calculate the pages $pages = $pagies->calculate_pages($count, $perPage, $p); //get the activity records $res = $DB->prepare("SELECT \r\n\t\t\t\t\t\t\t\t\t\t\t\t`article_comments`.`id`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t`article_comments`.`added`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t`article_comments`.`author`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t`article_comments`.`article`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t`article_comments`.`text`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t`account_data`.`displayName` AS `author_str` \r\n\t\t\t\t\t\t\t\t\t\t\tFROM `article_comments` \r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `account_data` ON `account_data`.`id` = `article_comments`.`author` \r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `article_comments`.`article` = :id \r\n\t\t\t\t\t\t\t\t\t\t\tORDER BY `article_comments`.`id` DESC \r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT " . $pages['limit'] . ";"); $res->bindParam(':id', $ArticleID, PDO::PARAM_INT); $res->execute(); //loop the records while ($arr = $res->fetch()) { echo ' <div class="comment_row" data-id="', $arr['id'], '"> <div class="headline"> <p><a href="', $config['BaseURL'], '/index.php?page=profile&uid=', $arr['author'], '">', $arr['author_str'], '</a> said:</p> <span id="time" data-original="', $arr['added'], '">NaN</span> </div> <p class="comment">', Articles::parseTitle($arr['text']), '</p> </div>'; }