2016-04-11 9 views
-2

jqueryを使用してオートロードページネーションを作成しようとしています。PDOを使用したオートロードページネーション

なぜこれは機能しませんか?
ページネーションにいくつか問題があります。私はデータベースコンソール上で直接クエリを実行し、正常に動作します。あなたは "}" の余分を持っているよう

if(isset($_GET['id'])) 
{ 
$get=$_GET['id']; 
} 
else 
{ 
$get=1; 
} 
$limit=6; 
$page = (int) (!isset($_GET['p'])) ? 1 : $_GET['p']; 
$sqlw = $connect->prepare("SELECT * FROM `product` WHERE `subid`=:subid"); 
$sqlw->bindParam(':subid',$get, PDO::PARAM_INT); 
$sqlw->execute(); 
$num_rows=$sqlw->rowCount(); 
$start = ($page * $limit) - $limit; 
if($num_rows>($page * $limit)) 
{ 
$next = ++$page; 
} 
$sa = $connect->prepare("SELECT * FROM `product` WHERE `subid`=:subid LIMIT :start,:limit"); 
$sa->bindParam(':subid',$get, PDO::PARAM_INT); 
$sa->bindParam(':start',$start, PDO::PARAM_INT); 
$sa->bindParam(':limit',$limit, PDO::PARAM_INT); 
$sa->execute(); 

while($f = $sa->fetch(PDO::FETCH_OBJ)) 
{ 
$f->id; 
$f->name; 
$f->detail; 
} 

} 
$s=$sa->rowCount(); 
if ($s < 1) 
{ 
header('HTTP/1.0 404 Not Found'); 
echo '<script>document.location.href="404.php";</script>'; 
exit(); 
} 

<?php if(isset($next)): ?> 
<div class="nav"> 
    <a href="category.php?p=<?php echo $next; ?>&id=<?php echo $get; ?>">»</a> 
</div> 
<?php endif?> 

答えて

0

は、whileループの最後にコードになります

$s=$sa->rowCount(); 
+0

しかし、それはまだ動作しません:

} $s=$sa->rowCount(); 

はする必要があります!!!!!!! –

関連する問題