Pagination works when there is no search query, but as soon as I search the pages do not filter through the search results.
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.btn-text-right{
text-align: right;
}
</style>
<meta charset="utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput-typeahead.css" />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tagmanager/3.0.2/tagmanager.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tagmanager/3.0.2/tagmanager.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="span12">
<h2 style="text-align:center"><strong>Explore Tracking Requests</strong></h2>
<div class="btn-text-right">
<form class="form-search pull-right" action="<?php echo $_SERVER['PHP_SELF'];?>" method="get">
<input type="text" name="query" class="input-medium search-query" value="<?php echo isset($_GET['query'])?$_GET['query']:'';?>">
<button type="submit" class="btn">Search</button>
<a href="create2.php" class="btn btn-success" >New</a>
<div class="span6">
</div>
</div>
</div>
<div class="row">
</form>
</div>
<div class="span12">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Analyst</th>
<th>Agency</th>
<th>Date</th>
<th>Requester</th>
<th>Firearm</th>
<th>Packets</th>
<th>Packets1</th>
<th>Summary</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
include 'paginator.php';
include 'database.php';
$pdo = Database::connect();
$paginator = new Paginator();
$sql = "SELECT count(*) FROM tracking ";
$paginator->paginate($pdo->query($sql)->fetchColumn());
$sql = "SELECT * FROM tracking ";
$query = isset($_GET['query'])?('%'.$_GET['query'].'%'):'%';
$sql .= "WHERE Title LIKE :query OR Analyst LIKE :query OR Agency LIKE :query OR Date LIKE :query OR Requester LIKE :query OR Summary LIKE :query OR ID LIKE :query ";
$start = (($paginator->getCurrentPage()-1)*$paginator->itemsPerPage);
$length = ($paginator->itemsPerPage);
$sql .= "ORDER BY Date DESC limit :start, :length ";
$sth = $pdo->prepare($sql);
$sth->bindParam(':start',$start,PDO::PARAM_INT);
$sth->bindParam(':length',$length,PDO::PARAM_INT);
$sth->bindParam(':query',$query,PDO::PARAM_STR);
$sth->execute();
foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $row) {
echo '<tr>';
echo '<td>'. $row['ID'] . '</td>';
echo '<td>'. $row['Title'] . '</td>';
echo '<td>'. $row['Analyst'] . '</td>';
echo '<td>'. $row['Agency'] . '</td>';
echo '<td>'. $row['Date'] . '</td>';
echo '<td>'. $row['Requester'] . '</td>';
echo '<td>'. $row['Firearm'] . '</td>';
echo '<td>'. $row['Packets'] . '</td>';
echo '<td>'. $row['Packets1'] . '</td>';
echo '<td>'. $row['Summary'] . '</td>';
echo '<td width=60>';
echo '<a class="btn btn-success" target=”_blank” href="update2.php?ID='.$row['ID'].'">Update</a>';
echo '</td>';
echo '</tr>';
}
Database::disconnect();
?>
</tbody>
</table>
<?php
echo $paginator->pageNav();
?>
</div>
</div>
</div> <!-- /container -->
</body>
</html>