I am trying to retain the $id value in a session so that i can use it effectively with the pagination...
if(empty($_GET["cat"])){
$session->message('<div class="error-msg">No product was selected.</div>');
redirect_to("view_all.php");
}else{
$id = $database->escape_value($_GET["cat"]);
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
$per_page = 50;
$sql = "SELECT COUNT(*) FROM products WHERE category='$id'";
$sql = $database->query($sql);
$sql = $database->fetch_array($sql);
$total_count = array_shift($sql);
$pagination = new Pagination($page, $per_page, $total_count);
$sql = "SELECT * FROM products WHERE category='$id'";
$sql .= " ORDER by id DESC";
$sql .= " LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()}";
$result = Product::find_by_sql($sql);
}