Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ajax错误,每页显示3个用户_Javascript_Php_Jquery_Mysql_Ajax - Fatal编程技术网

Javascript Ajax错误,每页显示3个用户

Javascript Ajax错误,每页显示3个用户,javascript,php,jquery,mysql,ajax,Javascript,Php,Jquery,Mysql,Ajax,我尝试使用jquery、mySql和PHP使用分页显示每页3个用户,因此我在本页中遵循一些教程: 我犯了两个错误 第一个错误是,我的平台不支持Mysql\u查询,所以我将其更改为Mysqli\u查询,以便修复它 第二个错误是页面只显示页码,没有用户信息 有人能帮我吗 这是一个显示页面状态的图像: 这些是我把它们改成Mysqli_查询后的文件 Config.php <?php $db_username = '****'; $db_password = '*****'; $db_na

我尝试使用jquery、mySql和PHP使用分页显示每页3个用户,因此我在本页中遵循一些教程:

我犯了两个错误

第一个错误是,我的平台不支持Mysql\u查询,所以我将其更改为Mysqli\u查询,以便修复它

第二个错误是页面只显示页码,没有用户信息

有人能帮我吗

这是一个显示页面状态的图像:

这些是我把它们改成Mysqli_查询后的文件

Config.php

    <?php

$db_username = '****';
$db_password = '*****';
$db_name = '*****';
$db_host = '********';
$item_per_page = 3;


$connecDB = mysqli_connect($db_host, $db_username, $db_password,$db_name)or die('could not connect to database');
?>
data.php

<?php
include('config.php');
$per_page = 3; 
if($_GET)
{
    $page=$_GET['page'];
}

//getting table contents
$start = ($page-1)*$per_page;
$sql = "select * from users order by id limit $start,$per_page";
$rsd = mysqli_query($sql);
?>



<table id="tb1">
        <th><b>Id</b></th>
        <th><b>FirstName</b></th>
        <th><b>Email</b></th>
        <th><b>LastName</b></th>
        <?php
        while($row = mysqli_fetch_array($rsd))
        {
            $id    = $row['id'];
            $fname = $row['first_name'];
            $mname    = $row['email'];
            $lname    = $row['last_name'];
        ?>
        <tr>
        <td><?php echo $id; ?></td>
        <td><?php echo $fname; ?></td>
        <td><?php echo $mname; ?></td>
        <td><?php echo $lname; ?></td>
        </tr>
        <?php
        } //End while
        ?>
</table>

<style>
#tbl
{
width:800px;
border:1px solid #000000;
margin-top:50px;
}

#tbl tr:nth-child(odd) {
  background: #000000
}

#tbl td{
border:1px solid #000000
}

#tbl th
{
  background: #00000;
border:1px solid #000000
}
</style>
index.php

<?php
include('config.php');
$per_page = 3; 

//getting number of rows and calculating no of pages

$sql = "select count(*) from users";
$result = mysqli_query($connecDB,$sql);
$count = mysqli_fetch_row($result);
$pages = ceil($count[0]/$per_page);

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>PHPDevZone : Pagination Using Mysql and jQuery </title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://yourjavascript.com/2141420575/pagination.js"></script>   
<style>
body { margin: 0; padding: 0; font-family:Verdana; font-size:15px }
a
{
text-decoration:none;
color:#000000;

}

a:hover
{

color:#DF3D82;
text-decoration:underline;

}
#loading { 
width: 100%; 
position: absolute;
}

#pagination
{
text-align:center;
margin-left:120px;

}
li{ 
list-style: none; 
float: left; 
margin-right: 16px; 
padding:5px; 
color:#0063DC; 
}
li:hover
{ 
color:#FF0084; 
cursor: pointer; 
}
</style>
</head>
<body>
<div align="center">
   <div style="margin-top:300px;"><b><a href="http://php-dev-zone.blogspot.com" > PHPDevZone </a></b>: Pagination Demo</div>
 <div id="content" ></div>
    <table width="800px">
    <tr><Td>
            <ul id="pagination">
                <?php
                //Show page links
                for($i=1; $i<=$pages; $i++)
                {
                    echo '<li id="'.$i.'">'.$i.'</li>';
                }
                ?>
           </ul>    
        </Td>
    </tr></table>
<div id="loading" ></div>
    </div> 
</body>
</html>
pagination.js

    $(document).ready(function(){

    //Loading Image Display
    function Display_Load()
    {
        $("#loading").fadeIn(100);
        $("#loading").html("<img src='loading.gif' />");
    }
    //Hide Loading Image
    function Hide_Load()
    {
        $("#loading").fadeOut('slow');
    };


   //Default Starting Page Results

    $("#pagination li:first").css({'color' : '#FF0084','border' : 'none'});
    $("#content").load("data.php?page=1", Hide_Load());

    //Pagination Click
    $("#pagination li").click(function(){
        Display_Load();

        //CSS Styles
        $("#pagination li")
        .css({'border' : 'solid #dddddd 1px'})
        .css({'color' : '#0063DC'});

        $(this)
        .css({'color' : '#FF0084'})
        .css({'border' : 'none'});

        //Loading Data
        var pageNum = this.id;
        $("#content").load("data.php?page=" + pageNum, Hide_Load());
    });
});

谢谢

问题在于Data.php页面中的mysqli_查询。 mysqli_查询首先需要一个数据库链接,然后才需要查询,因此您的代码必须是这样才能正常工作的:

<?php
include ('config.php');
$per_page = 3;
if ($_GET) {
    $page = $_GET['page'];
}

//getting table contents
$start = ($page - 1) * $per_page;
$sql = "select * from users order by id limit $start,$per_page";
$rsd = mysqli_query($connecDB,$sql);
?>



<table id="tb1">
        <th><b>Id</b></th>
        <th><b>FirstName</b></th>
        <th><b>Email</b></th>
        <th><b>LastName</b></th>
        <?php
        while($row = mysqli_fetch_array($rsd))
        {
            $id    = $row['id'];
            $fname = $row['first_name'];
            $mname    = $row['email'];
            $lname    = $row['last_name'];
        ?>
        <tr>
        <td><?php echo $id; ?></td>
        <td><?php echo $fname; ?></td>
        <td><?php echo $mname; ?></td>
        <td><?php echo $lname; ?></td>
        </tr>
        <?php } //End while ?>
</table>

<style>
    #tbl {
        width: 800px;
        border: 1px solid #000000;
        margin-top: 50px;
    }

    #tbl tr:nth-child(odd) {
        background: #000000
    }

    #tbl td {
        border: 1px solid #000000
    }

    #tbl th {
        background: #00000;
        border: 1px solid #000000
    }
</style>

非常感谢您的回复i change the data.php,但是问题仍然存在索引页没有显示任何用户ID您更改了查询吗$sql=从用户订单中选择*按id限制$start$每页;因为我把mybb_用户改成了用户。您确定表中有数据吗?是的,我更改了查询,并且我确定表中的数据超过5条记录谢谢您的响应抱歉,我看不到您的代码有任何错误,除了一些不重要的未定义变量错误。如果你愿意,我可以在ymsgr:tje3dATy上帮助你!我真的尝试了每件事,我不知道为什么它不起作用,也许data.php和index.php之间存在连接问题,如果你能帮我做任何事情,请谢谢