/** * This method is used to display the pagination object. * * @return string HTML mix tags. */ public function Display() { $buttonFirst = new ButtonFirst(); $buttonPrevious = new ButtonPrevious(); $buttonNext = new ButtonNext($this->Last_Page); $buttonLast = new ButtonLast($this->Last_Page); $perPage = new PerPage(); $pagenumber = new PageNumber(isset($_REQUEST['Page_Number']) ? $_REQUEST['Page_Number'] : 1, $this->Last_Page); return $buttonFirst->Display() . $buttonPrevious->Display() . $buttonNext->Display() . $buttonLast->Display() . $perPage->Display() . $pagenumber->Display(); }
<?php require_once "dbcontroller.php"; require_once "pagination.class.php"; $db_handle = new DBController(); $name = ""; $code = ""; $perPage = new PerPage(); $queryCondition = ""; if (!empty($_POST["name"])) { $queryCondition .= " WHERE name LIKE '" . $_POST["name"] . "%'"; } if (!empty($_POST["code"])) { if (!empty($queryCondition)) { $queryCondition .= " AND "; } else { $queryCondition .= " WHERE "; } $queryCondition .= " code LIKE '" . $_POST["code"] . "%'"; } $orderby = " ORDER BY id desc"; $sql = "SELECT * FROM toy " . $queryCondition; $paginationlink = "getresult.php?page="; $page = 1; if (!empty($_GET["page"])) { $page = $_GET["page"]; } $start = ($page - 1) * $perPage->perpage; if ($start < 0) { $start = 0; }