我看过这么多教程,但它没有用。我从过去 3 天开始尝试这个东西,最后我需要你们帮助我。我是 php 的初学者,所以请逐步解释。百thanx在先进......
这是我的CSS代码:
div.pagination
{
width:625px;
clear:both;
padding:10px 0 10px 0;
margin:0px;
text-align:center;
float:left;
clear:both;
font-size:11px;
}
div.pagination a
{
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #52bfea;
text-decoration: none;
color: #52bfea;
}
div.pagination a.current
{
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #52bfea;
font-weight: bold;
background-color: #52bfea;
color: #FFF;
}
div.pagination a:hover, div.pagination a:active
{
border:1px solid #52bfea;
color: #fff;
background-color: #52bfea;
}
这是我的php代码:
<div class="pagination">
<?php
if($pagination->total_pages() > 1)
{
?>
<?php
if($pagination->has_previous_page())
{
?>
<a href="index.php?page=<?php echo $pagination->previous_page();?>"><< prev</a>
<?php
}
?>
<?php
for($i=1; $i <= $pagination->total_pages(); $i++)
{
$class = ($i==isset($_GET['page']))? 'current' : '';
?>
<a class='<?php echo $class?>' href="test.php?page=<?php echo $i; ?>"><?php echo $i?></a>
<?php
}
?>
<?php
if($pagination->has_next_page())
{
?>
<a href="index.php?page=<?php echo $pagination->next_page();?>"> next >></a>
<?php
}
?>
<?php
}
?>
</div>
</div>