1.建立连接2.设定每页显记录数n3.查询数据4.关闭连接 每页n条记录,显示第i页,开始记录数s=?s = ( $i - 1 ) * n <? php $connect = mysql_pconnect ( " localhost " , " root " , " root " ); mysql_select_db ( " UserInfo " , $connect ); $page_num = 10 ; // 每页记录数 if ( ! $page_no ){ $page_no = 1 ; } $start_num = $page_num * ( $page_no - 1 ) // 页号$page_no $sql = " select * from UserInfo limit $start_num, $page_num " $result = mysql_query ( $sql ); $rows = @ mysql_num_rows ( $result ); for ( $i = 0 ; $i < $rows ; $i ++ ){ @ mysql_data_seek ( $result , $i ); $data = @ mysql_fetch_array ( $result ); echo " <pre " ; echo " id: $data[id], username: $data[username], " ; echo " password: $data[password], name: $data[name] " ; echo " </pre> " ; } echo " <a href='exa9-1.php?page_no= " . ( $page_no - 1 ) . " '>上一页</a>$nbsp;$nbsp;$nbsp;<a href='exa9-1.php?page_no= " . " '>下一页</a><br> " ; ?>