Need some help if possible?
Iām trying to add pagination to my code.. The problem I am getting is the pagination script works perfectly well without the JOIN statement and the JOIN statement works when I exclude the pagination script so they both work just not together.
It counts the results correctly with both scripts together just wont show the data.
The question is how do I get them to work together as I get an error:
Any help would be grateful
ini_set('display_errors', 1);
error_reporting(~0);
$Keyword = null;
if(isset($_POST["term"])){
$Keyword = $_POST["term"];
}
if(isset($_GET["term"])){
$Keyword = $_GET["term"];
}
$sql = "SELECT * FROM table1
INNER JOIN table2 ON (table1.member_id = members.id)
WHERE MATCH (name,location) AGAINST ('%".$Keyword."%' IN NATURAL LANGUAGE MODE)";
$query = mysqli_query($conn,$sql);
$num_rows = mysqli_num_rows($query);
$per_page = 2;
$page = 1;
if(isset($_GET["Page"])) {
$page = $_GET["Page"];
}
$prev_page = $page-1;
$next_page = $page+1;
$row_start = (($per_page*$page)-$per_page);
if($num_rows<=$per_page) {
$num_pages =1;
} else if(($num_rows % $per_page)==0) {
$num_pages =($num_rows/$per_page) ;
} else {
$num_pages =($num_rows/$per_page)+1;
$num_pages = (int)$num_pages;
}
$row_end = $per_page * $page;
if($row_end > $num_rows) {
$row_end = $num_rows;
}
$sql .= "SELECT * ORDER BY ID ASC LIMIT $row_start ,$row_end ";
$query = mysqli_query($conn,$sql);
while($result=mysqli_fetch_array($query,MYSQLI_ASSOC)) {