Favori
2015-06-16 11:36
<?php $page = $_GET['p']; $host = "localhost"; $username = 'root'; $password = ''; $db = 'test'; $conn = mysql_connect($host, $username, $password); if(!$conn){ echo "数据库连接失败"; exit; } mysql_select_db($db); mysql_query('SET NAMES UTF8'); $sql="SELECT * FROM page LIMIT".(($page-1) * 10).",10"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)){ echo $row['id'].'-'.$row['name']; } ?>
LIMIT 后面要加空格,否则变成LIMIT1,关键字就错误了
说明错误原因
PHP+MySQL分页原理实现
41180 学习 · 175 问题
相似问题