2 u010990330 u010990330 于 2013.11.23 23:23 提问

php网页制作数据库的翻页显示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档




<?php include("top.php")?>


<?php include("left.php")?>



检索结果



<?php
$conn = mysql_connect("localhost:3306","root","123456") or die("数据连接失败".mysql_error());
mysql_select_db("db",$conn) or die("数据库选择失败".mysql_error());
mysql_query("set names utf8");
if(!empty($_REQUEST['test1']))
{
$content = $_REQUEST["test1"];
$type = $_REQUEST["select"];
$sql = mysql_query("select * from tb_info where checkstate=1 and type='$type' and(content like'%$content%' or title like'%$content%' or linkman like'%$content%' or tel like'%$content%')");
$rbll = mysql_num_rows($sql);
if(!empty($_GET["find"]))
$sessin = $_GET["find"];//当前页
if(!isset($sessin)){
$sessin = 1;
}
//echo $sessin;
$c = 6;//每次要显示在页面上的记录条数
$s = ceil($rbll/$c-1);//一共分几页
$p = ($sessin-1)*$c;//从第几条记录开始显示
$sql = mysql_query("select * from tb_info where checkstate=1 and type='$type' and(content like'%$content%' or title like'%$content%' or linkman like'%$content%' or tel like'%$content%')limit $p,$c");

$rowb= mysql_fetch_array($sql);
if($rbll>0)
{
                                do{?>
                                    <table height="100" border="0">
                                        <tr>
                                            <td height="26">
                                                【<?php echo str_replace($content,"<font color='#FF0000'>".$content."</font>",$rowb["type"]);?>】
                                                <?php echo str_replace($content,"<font color='#FF0000'>".$content."</font>",$rowb["title"]);?>&nbsp;&nbsp;
                                                <?php echo str_replace($content,"<font color='#FF0000'>".$content."</font>",$rowb["edate"]);?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="26">
                                                <?php echo str_replace($content,"<font color='#FF0000'>".$content."</font>",$rowb["content"]);?>&nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="26">联系人:
                                                <?php echo str_replace($content,"<font color='#FF0000'>".$content."</font>",$rowb["linkman"]);?>&nbsp;&nbsp;
                                                联系电话:<?php echo str_replace($content,"<font color='#FF0000'>".$content."</font>",$rowb["tel"]);?>
                                            </td>
                                        </tr>
                                    </table>
                                    <div style="width:561px; border-bottom:1px dashed #CCCCCC;"></div> 
                            <?php }while($rowb = mysql_fetch_array($sql));
                            }
                    ?>
                </div>
                <div style="width:560px; height:20px; border:1px #000000 solid; margin-left:217px; font-size:13px;">
                         <?php echo "当前为第".$sessin."页";
                            echo "共".$s."页";
                            echo "  ";
                            echo "共".$c."条记录";
                         ?> 
                        <?php
                            $prev_page = $sessin - 1;//定义上一页为该页减一
                            $next_page = $sessin + 1;//定义下一页为该页加一
                          if($sessin<=1)
                            {
                            echo "<a href='find.php?find=1'>首页</a>";
                            }
                           else
                            {

                                echo"<a href='find.php?find=1'>首页</a>";
                            }
                            if($prev_page<=1)
                            {
                                echo "上一页";   
                            }
                            else
                            {
                                echo"<a href='find.php?find=$prev_page'>上一页</a>";
                            }
                            if($prev_page>$s)
                            {
                                echo "下一页";
                            }
                            else
                            {
                                echo"<a href='find.php?find=$next_page'>下一页</a>";

                             }
                            if($sessin>=$s)
                            {
                                echo "尾页";
                            }
                            else
                            {
                                echo"<a href='find.php?find=$s'>尾页</a>";
                            }
                        }
                    ?>
                </div>      
         </div>
        <div style="clear:both">
            <?php include("bottom.php")?>
        </div>
    </div>


求大神帮忙看一下我那写错了 翻页后数据不显示 帮忙改正 谢谢。。。。。。

1个回答

lingshuanglong
lingshuanglong   2015.08.03 17:18
已采纳

应该是你的下一页链接里没有把相关的参数重新传回到本页。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!