我得到了一些問題問題,下一個先前頁pagenition
注意:未定義的變量:用C pageination:\ XAMPP \ htdocs中\ pagge \ pagenition.php上線28
注意:未定義的變量:上一頁在C:\ XAMPP \ htdocs中\ pagge \ pagenition.php上線29
警告:mysql_fetch_array()預計參數1是資源,在布爾C中給出:\ XAMPP \ htdocs中\ pagge \ pagenition.php在線41上我的代碼
<?php
require("conn.php");
$count_query = mysql_query("SELECT null FROM product");
$count = mysql_num_rows($count_query);
if(isset($_GET['page'])){
$page=preg_replace("#[^0-9]#","",$_GET['page']);
}else{
$page = 1;
}
$perPage = 2;
$lastPage = ceil($count/$perPage);
$limit = "LIMIT". ($page-1)*$perPage .", $perPage";
$query = mysql_query("SELECT P_name FROM product ORDER BY P_id DESC '$limit'");
if($lastPage!=1){
if($page != $lastPage){
$next = $page + 1;
$pageination .= '<a href= "pagenition.php?page='.$next.">NEXT </a>" ;
}
}
if($lastPage!=1){
if($page != $lastPage){
$prev = $page - 1;
$pageination .= '<a href= "pagenition.php?page='.$prev.">Prev </a>" ;
}
}
while($row=mysql_fetch_array($query)){
$output .= $row['P_name'] . "<hr/>";
}
?>
<html>
<body>
<h1> pagenition example </h1>
<?php echo $output ?>
<?php echo $pageination ?>
</body>
</html>
[PHP:「Notice:Undefined variable」和「Notice:Undefined index」]的可能重複(http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-索引) – Justinas 2014-11-24 11:55:55
假設'pagenition.php'存在,位於'C:\ xampp \ htdocs \ pagge \'? – Alex 2014-11-24 11:56:04
在mysql_query()之後在'require(「conn.php」);' – 2014-11-24 11:56:27