终于运行成功
<?php
//连接数据库
error_reporting(0);
mysql_connect('127.0.0.1', 'code1', '');
mysql_select_db('code1');
mysql_query("set names 'utf8'");
//预设翻页参数
$page = 2;
$pagesize = 2;
//offset就相当于当前第几条数据
$offset = ($page-1)*$pagesize;
//从第几条数据开始,显示几条数据
$sql = '"select * from user limit $offset,$pagesize"';
//获取翻页数据
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$data[] = $row;
}
echo '<pre>';
print_r($data);
echo '</pre>';