$sql .= $value_oby . ' ' . $search_asc_desc[$key_oby] . ' ,'; $all_download_sql .= $value_oby . ' ' . $search_asc_desc[$key_oby] . ' ,'; } $sql = rtrim($sql, ','); $all_download_sql = rtrim($all_download_sql, ','); } else { $sql .= ' ORDER BY ' . $search_order_by . ' ' . $search_asc_desc; $all_download_sql .= ' ORDER BY ' . $search_order_by . ' ' . $search_asc_desc; } } $total_count = $class::count_all_by_sql($count_sql); if (!empty($per_page)) { $pagination = new pagination($pageno, $per_page, $total_count); $pagination_statement = $pagination->show_pagination(); $sql .= " LIMIT {$per_page} "; $sql .= " OFFSET {$pagination->offset()}"; } $search_result = $class::find_by_sql($sql); if (method_exists($class, 'search_add_extra_fields')) { $class::search_add_extra_fields($search_result); } if (property_exists($class, 'search')) { foreach (${$class}->search as $searchParaKey => $searchParaValue) { $s->setProperty($searchParaKey, $searchParaValue); } } $s->setProperty('result', $search_result); $s->setProperty('_searching_class', $class); $s->setProperty('_search_order_by', filter_input(INPUT_GET, 'search_order_by')); $s->setProperty('_search_asc_desc', filter_input(INPUT_GET, 'search_asc_desc')); $s->setProperty('_per_page', $per_page);
</span> </p> <?php /** * prepare to paginate comments * display paginated comments * built pagination link */ //1. the current page number($current_page) $paginate = !empty($_GET['paginate']) ? (int) $_GET['paginate'] : 1; //2. records per page ($per_page) $per_page = 3; //3. total record count ($total_count) $total_count = $dbo->count_number_rows($comment_set); $pagination = new pagination($paginate, $per_page, $total_count); $offset = $pagination->offset(); $comments = comment::paginate_comments($per_page, $offset); ?> <?php while ($comment = $dbo->fetch_assoc($comments)) { $author = utility::remove_escape($comment["author"]); $content = utility::remove_escape($comment["body"]); echo "<p><code><strong>{$author}</strong><br />"; echo " {$content} </code></p>"; } ?> <div id="pagination"><?php echo $pagination->built_pagination_links($paginate); ?>