PHP проблемы с нумерацией страниц
I am trying to make an pagination example.The problem is sql query .When I try something like this $query=$conn->db->prepare("select * from konular limit 3"); Everything is ok code works as intended But When I try something like this nothing happens $query=$conn->db->prepare("select * from konular limit".$limit.",".$perpage); I dont understand what am i doing wrong
Что я уже пробовал:
<?php require "conn.php"; require "funct.php"; $conn=new conn(); $funct=new funct(); $perpage=2; $totalCount= $funct->total(); $pageCount=ceil($totalCount/$perpage); $currentPage=isset($_GET["page"])?(int)$_GET["page"]:"1"; if($_GET["page"]<0){ $_GET["page"]="1"; }else if($_GET["page"]>$pageCount){ $_GET["page"]=$pageCount; } $limit=($currentPage-1)*$perpage; $query=$conn->db->prepare("select * from konular limit".$limit.",".$perpage); $query->execute(); $pages=$query->fetchAll(PDO::FETCH_ASSOC); foreach ($pages as $key => $value) { echo $key; }