分页代码中的错误 [英] error in pagination code

查看:88
本文介绍了分页代码中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我在我的分页脚本中遇到以下错误请帮我解决这个问题。



警告:mysql_fetch_array()期望参数1为资源,第16行的D:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ br />
以下是我的剧本





db.php



 <?php  
mysql_connect( localhost root );
mysql_select_db( library);
?>





data.php

 <?php  

include(' ../ db.php');
if($ _ GET [' page'])
{
$ page = $ _ GET [' page'];
}
$ per_page_num = 2;
$ offset =($ page-1)* $ per_page_num ;
$ getdata =( select * from作者限制$ offset,1);
$ checking = mysql_query($ getdata);
// if($ checking === FALSE){
// die(mysql_error()); // TODO:更好的错误处理
// }

while ($ rows = mysql_fetch_array($ checking))
{
?> ;

<? = $ rows [' < span class =code-string> name'
] ?> < < span class =code-leadattribute> br / >
<? php
}
?>





delt.php



 <?php  
include( ../ db.php);

$ query = mysql_query( select * from author);
$ count = mysql_num_rows($ query);
$ per_page = 1;
$ total = ceil($ count / $ per_page);
?>
< ul id = paginate >
<? php
for ($ i = 1; $ i< = $ total; $ i ++)
{
< span class =code-pagedirective>?>
< li id = <?= $ i?> > <? = $ i ?> < /利 <跨度class =code-keyword>>
<? php
}
?>
< / ul >
< div < span class =code-attribute> id = content > < / div >
< div id = load > < / div >
< script src = ../ jquery.js 类型 = text / javascript > < / script >
< script >
$(document).ready(function(){
function display(){
$( #load)。fadeIn( slow);
$( #load)。html(' < img src =https://themarketingoak.files.wordpress.com/2015/07/circle-loading-animation.gif>' );
}
function hide(){
$( #load)。fadeOut( 3000 );
}
$( #patchate li:first)。css( {color: red});
display();

$( #content)。load(' data.php?page = 1',hide());
$( #pateate li)。click(function(){
display();
$( #pateate li)。css({color : blue});
$( this )。css({color: red});
var num = $( this )。id;
$( #content)。load(' data.php?page =' + num,hide());
});
});
< / script >

解决方案

_GET [' page'])
{


page =

_GET [' page'];
}


hello friends,

I am facing following error in my pagination script please help me to solve this.

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\lib\author\data.php on line 16

following is my script


db.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("library");
?>



data.php

<?php

include('../db.php');
if($_GET['page'])
{
    $page =$_GET['page'];
}
$per_page_num=2;
$offset = ($page-1)* $per_page_num;
$getdata = ("select * from author limit $offset,1");
$checking = mysql_query($getdata);
//if($checking=== FALSE) {
 //   die(mysql_error()); // TODO: better error handling
//}

while ($rows = mysql_fetch_array($checking))
{
    ?>

    <?=$rows['name']?><br/>
    <?php
}
?>



delt.php

<?php
include("../db.php");

$query = mysql_query("select * from author");
$count = mysql_num_rows($query);
$per_page=1;
$total = ceil($count/$per_page);
?>
<ul id="paginate">
    <?php
    for ($i=1;$i<=$total;$i++)
    {
        ?>
        <li id="<?=$i?>"><?=$i?></li>
    <?php
    }
    ?>
</ul>
<div id="content"></div>
<div id="load"></div>
<script src="../jquery.js" type="text/javascript"></script>
<script>
    $(document).ready(function(){
        function display(){
            $("#load").fadeIn("slow");
            $("#load").html('<img src="https://themarketingoak.files.wordpress.com/2015/07/circle-loading-animation.gif">');
        }
        function hide(){
            $("#load").fadeOut(3000);
        }
        $("#paginate li:first").css({color:"red"});
        display();

        $("#content").load('data.php?page=1',hide());
        $("#paginate li").click(function(){
           display();
            $("#paginate li").css({color:"blue"});
            $(this).css({color:"red"});
            var num=$(this).id;
            $("#content").load('data.php?page='+ num,hide());
        });
    });
</script>

解决方案

_GET['page']) {


page =


_GET['page']; }


这篇关于分页代码中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆