为了账号安全,请及时绑定邮箱和手机立即绑定

为什么写的css样式,只对第一页生效呢?求大神指教

为什么写的css样式,只对第一页生效呢?求大神指教

PHP
wenzki 2016-01-23 23:36:33
<html><head><meta http-equiv="Content-type" content="text/html;charset=utf-8"><style>body{font-size: 12px;font-family: verdana;width: 100%;}.page a{border:red 1px solid;text-decoration:none;padding: 2px 5px 2px 5px;margin: 2px;}.page span.current{border: #000099 1px solid;background-color: #000099;padding: 4px 6px 4px 6px;margin: 2px;color:#ffffff;font-weight: bold;}.page span.disable{border: #eee 1px solid;padding: 2px 5px 2px 5px;margin: 2px;color:#ddd; }.page {text-align: center;}.page form{display: inline;}.content{height: 280px;}</style></head><body><?php header("Content-type=text/html;charset=utf-8"); //1、传入页码 $page = $_GET['p']; $pagesize=10; $off=($page-1)*10; $showPage=5; //2、根据页码取数据 $host='localhost'; $username='root'; $password='123465'; $db='mallbuilders'; $conn=mysql_connect($host,$username,$password); if(!$conn){ die("数据库连接失败!"); exit; } mysql_select_db("wenzki"); mysql_query("set names utf8"); //编写sql $sql="SELECT * FROM wenzki order by id asc LIMIT ".$off.",".$pagesize; $result=mysql_query($sql) or die(mysql_error()); echo "<div class='content'>"; echo "<table border=1 cellspacing=0 width=40% align=center>"; echo "<tr><th>ID</th><th>地址</th></tr>"; while($row=mysql_fetch_assoc($result)){ /*echo $row['id']."<br/>";*/ echo "<tr>"; echo "<td>{$row['id']}</td>"; echo "<td>{$row['user_email']}</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; //获取数据总数 $total_sql="select COUNT(*) from wenzki"; $total_res=mysql_query($total_sql) or die(mysql_error()); $res=mysql_fetch_array($total_res); $total=$res[0]; //计算页数 $total_pages=ceil($total/$pagesize); /*释放结果集,关闭结果*/ mysql_free_result($result); mysql_close($conn); //3、显示数据+分页条 $page_banner="<div class='page'>"; //偏移量 $pageoffset=($showPage-1)/2; if($page>1){ $page_banner="<a href='".$_SERVER['PHP_SELF']."?p=1'>首页</a>"; $page_banner.="<a href='".$_SERVER['PHP_SELF']."?p=".($page-1)."'><上一页</a>"; }else{ $page_banner.="<span class='disable'>首页</span>"; $page_banner.="<span class='disable'><上一页</span>"; } //初始化数据 $start=1; $end=$total_pages; if ($total_pages>$showPage) { if ($page>$pageoffset+1) { $page_banner.="..."; } if($page>$pageoffset){ $start=$page-$pageoffset; $end=$total_pages>$page+$pageoffset?$page+$pageoffset:$total_pages; }else{ $start=1; $end=$total_pages>$showPage?$showPage:$total_pages; } if($page+$pageoffset>$total_pages){ $start=$start-($page+$pageoffset-$end); }} for($i=$start;$i<=$end;$i++){ if($page==$i){ $page_banner.="<span class='current'>{$i}</span>"; }else{ $page_banner.="<a href='".$_SERVER['PHP_SELF']."?p=".$i."'>{$i}</a>"; } } //省略尾部 if($total_pages>$showPage&&$total_pages>$page+$pageoffset){  $page_banner.="...";  } if($page<$total_pages){ $page_banner.="<a href='".$_SERVER['PHP_SELF']."?p=".($page+1)."'>下一页></a>"; $page_banner.="<a href='".$_SERVER['PHP_SELF']."?p=".($total_pages)."'>尾页</a>"; }else{ $page_banner.="<span class='disable'>尾页</span>"; $page_banner.="<span class='disable'>下一页></span>"; } $page_banner.="共{$total_pages}页"; $page_banner.="<form action='index.php' method='get'>"; $page_banner.="到第<input type='text' size='2' name='p'>页"; $page_banner.="<input type='submit' value='确定'>"; $page_banner.="</form></div>"; echo $page_banner; ?> </body> </html>
查看完整描述

2 回答

?
wenzki

TA贡献1条经验 获得超1个赞

$page_banner="<div class='page'>";

//偏移量

$pageoffset=($showPage-1)/2;


if($page>1){

$page_banner="<a href='".$_SERVER['PHP_SELF']."?p=1'>首页</a>";

已解决,这里少了一个点

查看完整回答
1 反对 回复 2016-03-21
?
php_go

TA贡献16条经验 获得超24个赞

<h1>不应该吧</h1>

查看完整回答
反对 回复 2016-01-24
  • 2 回答
  • 0 关注
  • 1791 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信