sanitize($_GET['keyword']); $bind_keyword = "%".$keyword."%"; } else { $keyword = ""; $bind_keyword = $keyword; } if (empty($keyword)) { $sql_query = "SELECT cid, category_name, category_image FROM tbl_category ORDER BY cid DESC"; } else { $sql_query = "SELECT cid, category_name, category_image FROM tbl_category WHERE category_name LIKE ? ORDER BY cid DESC"; } $stmt = $connect->stmt_init(); if ($stmt->prepare($sql_query)) { // Bind your variables to replace the ?s if (!empty($keyword)) { $stmt->bind_param('s', $bind_keyword); } // Execute query $stmt->execute(); // store result $stmt->store_result(); $stmt->bind_result( $data['cid'], $data['category_name'], $data['category_image'] ); // get total records $total_records = $stmt->num_rows; } // check page parameter if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } // number of data that will be display per page $offset = 10; //lets calculate the LIMIT for SQL, and save it $from if ($page) { $from = ($page * $offset) - $offset; } else { //if nothing was given in page request, lets load the first page $from = 0; } if (empty($keyword)) { $sql_query = "SELECT cid, category_name, category_image FROM tbl_category ORDER BY cid DESC LIMIT ?, ?"; } else { $sql_query = "SELECT cid, category_name, category_image FROM tbl_category WHERE category_name LIKE ? ORDER BY cid DESC LIMIT ?, ?"; } $stmt_paging = $connect->stmt_init(); if ($stmt_paging ->prepare($sql_query)) { // Bind your variables to replace the ?s if (empty($keyword)) { $stmt_paging ->bind_param('ss', $from, $offset); } else { $stmt_paging ->bind_param('sss', $bind_keyword, $from, $offset); } // Execute query $stmt_paging ->execute(); // store result $stmt_paging ->store_result(); $stmt_paging->bind_result( $data['cid'], $data['category_name'], $data['category_image'] ); // for paging purpose $total_records_paging = $total_records; } // if no data on database show "No Reservation is Available" if ($total_records_paging == 0) { ?>

MANAGE CATEGORY

Category Name Category Image Action
Wopps! No data found with the keyword you entered.

MANAGE CATEGORY

fetch()) { ?>
Category Name Category Image Action
mode_edit delete

doPages($offset, 'manage-category.php', '', $total_records, $keyword); ?>