现在,我正在开展一个项目,我需要在一个页面上显示来自不同表格的数据,一个接一个地使用滚动功能
对于这项任务,我使用的是ajax,php,mysql。
所以这就是我到目前为止所做的:
PHP代码:
<?php
$conn = mysqli_connect("127.0.0.1", "Got", "nokia", "myddb");
$feedb = mysqli_query($conn,"SELECT * FROM feedb");
$feedb_count=mysqli_num_rows($feedb);
$photo = mysqli_query($conn,"SELECT * FROM photob");
$photo_count=mysqli_num_rows($photo);
$limito=$_POST["limit"];
$pagefeed=$_POST["start"];
$pagephoto=$_POST["startphoto"];
$pagetexto=$_POST["start3"];
$tumb=$_POST["change"];
if($tumb==0)
{
$query = "SELECT * FROM feedb ORDER BY cid DESC LIMIT $pagefeed , $limito ";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($result))
{
echo "
<div class=\"block\">
<img class=\"imago\"src=\"img/$row[cphoto].jpg\">
<span class=\"namo\">$row[cname]</span><br>
<span class=\"texto\">$row[ctext]</span>
</div>"."Page".$pagefeed."Func".$tumb;
}
}
if($tumb==1)
//echo "<br>"."Page".$pagefeed."Func".$tumb;
{
$query = "SELECT * FROM textb ORDER BY cid DESC LIMIT $pagephoto , $limito ";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($result))
{
echo "
<div class=\"block\">
<span class=\"namo\">$row[cname]</span><br>
<span class=\"texto\">$row[ctext]</span>
</div>";
}
}
Javascript代码:
<script>
$(document).ready(function(){
var limit = 7;
var start = 35;
var start2 = 0;
var start3 = 0;
var action = 'inactive';
var change = 0;
var ncount =0;
if(active='inactive'){
action='active';
load_country_data();
}
function load_country_data()
{
$.ajax({
url:"resout.php",
method:"POST",
data:{limit:limit,start:start,change:change,startphoto:start2},
cache:false,
success:function(dataz)
{
$('#load_data').append(dataz);
if(dataz == '')
{
action = 'inactive';
change++;
if(change==2){action = 'active'; $('#load_data_message').html('Больше нету данных'); }
}
else
{
$('#load_data_message').html("<button type='button' class='btn btn-warning'>Please Wait....</button>");
action = "inactive";
}
}
});
}
$(window).scroll(function(){
if(($(window).scrollTop() + $(window).height())==$(document).height() && action == 'inactive' && change==0)
{
action = 'active';
start=start+limit; setTimeout(function(){load_country_data();}, 300);
}
else if(($(window).scrollTop() + $(window).height())==$(document).height() && action == 'inactive' && change==1)
{
action = 'active';
setTimeout(function(){load_country_data();}, 300);
start2=((ncount-1)*limit);ncount++;
}
});
});
</script>
但是在显示一个基数后,当它开始显示第二个时它有一个错误
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
错误后它会正确显示第二个碱基。 我认为这个问题是因为我选择了一种方法来显示第二个基数&#34; star2 =(ncount-1)* limit; ncount ++&#34;,但我没有看到不同的解决方案。
如何解决此问题或如何显示不同的问题 表以不同的方式?