首页 > php代码 > php分页代码(完整php mysql 经典分页实例)(1/2)

php分页代码(完整php mysql 经典分页实例)(1/2)

html代码

 代码如下 复制代码

<table width="100%" border="0" valign="top" align="center" cellpadding="0" cellspacing="0" >
  <tr>
    <td valign="top">
 
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#cccccc" class="all" id="tr"> 

          <tr >
            <td align="center" bgcolor="#d4e6ec" >id</td>
            <td height="28" align="left" bgcolor="#d4e6ec" >标题</td>
            <td align="left" bgcolor="#d4e6ec" >日期</td>
          </tr> 
<?php include_once("page.php"); ?> 
<?php
$conn=mysql_connect("localhost","root","") or die("不能连接数据库教程:".mysql_error());
$db=mysql_select_db("dbtest") or die("选择数据库错:".mysql_error());
mysql_query("set names gb2312");

$sql="select * from test order by id ";
genpage($sql,3); //这里引用了第一个函数 后面数字定义每页记录数
$result=mysql_query($sql) or die ("数据库操作出错:".mysql_error());
while ($row=mysql_fetch_array($result))
{
?>

          <tr >
            <td width="55" align="center" bgcolor="#ffffff" ><?php echo $row['id'] ?> </td>
            <td width="383" height="28" align="left" bgcolor="#ffffff" ><?php echo $row['title'] ?></td>
            <td width="162" align="left" bgcolor="#ffffff" ><?php echo $row['editdate'] ?></td>
          </tr>

<?php
}
?>
          <tr>
            <td height="30" colspan="3" align="center" bgcolor="#d4e6ec"><?php showpage();//这里引用了第二个函数 ?></td>
          </tr>
      </table>

 

本文地址:http://www.phprm.com/code/33940.html

转载随意,但请附上文章地址:-)

标签:none

发表留言