zl程序教程

您现在的位置是:首页 >  后端

当前栏目

php编写的简单页面跳转功能实现代码

PHP代码 实现 简单 功能 页面 编写 跳转
2023-06-13 09:15:13 时间
不多说,直接上代码
复制代码代码如下:

//链接数据库"查询
mysql_connect("localhost","username","userpwd")ordie("数据库链接失败".mysql_error());
mysql_select_db("库名");
mysql_query("setnamesutf8");
$sql1="select*fromuser";
$query1=mysql_query($sql1);
$count=array();
while($row=mysql_fetch_assoc($query1)){
   $count[]=$row;
}
$totalnews=count($count);
//判断page
if($_GET["page"]){
   $page=$_GET["page"];
}else{
   $page=1;
}
$start=($page-1)*$newnum;
  $sql="select*fromuserlimit$start,$newnum";
  $query=mysql_query($sql);
  $ret=array();
  while($row=mysql_fetch_assoc($query)){
      $ret[]=$row;
      }
?>
//表格样式
<divid="wrap"style="width:100%;height:100%;">
  <tableborder="1px";style="border-collapse:collapse;border:1pxsolid#000;width:100%;height:100%">
    <?phpforeach($retas$key=>$value){?>
      <tr>
          <td><?phpecho$value["id"]?></td>
          <td><?phpecho$value["username"]?></td>
          <td><?phpecho$value["pwd"]?></td>
          <td>删除|修改</td>
      </tr>
    <?php}?>
    <tr>
//页面跳转
          <tdcolspan="4"align="center"><ahref="upload.php?page=1">首页</a><ahref="upload.php?page=<?phpecho$lastpage?>">上一页</a><?phpecho$page;?>/<?phpecho$pagenum;?><ahref="upload.php?page=<?phpecho$nextpage;?>">下一页</a><ahref="upload.php?page=<?phpecho$pagenum?>">尾页</a><inputtype="text"name="text"/><inputtype="button"value="跳转"onclick="check(this)"/>
          </td>
    </tr>
  </table>
</div>