1
2 개의 PHP 파일과 MySql 데이터베이스를 사용하는 샘플 페이지가 있으며 jQuery 무한 스크롤을 사용하려고합니다. 데이터베이스에서 다음 데이터 그룹을로드하려면 어떻게해야합니까? 예를 들어 사진 데이터베이스에 100 개의 레코드가 있고 스크롤을 한 후 20, 다음 20을 표시하려고합니다.무한 스크롤에 대한 쿼리 결과 매김 방법?
이 내 현재의 핵심입니다 :
index.php를
<?php
ob_start();
require_once('images.html');
ob_end_flush();
?>
images.html 당신은 당신의 쿼리에 LIMIT
를 추가 할 필요가
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> trata tata</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" href="./css/style.css" />
<!-- scripts at bottom of page -->
</head>
<body class="demos ">
<nav id="site-nav">
<h1><a href="./index.html">ole tu jest HOME</a></h1>
<h2>Menu 1</h2>
<ul class="docs-list">
<li><a href="../docs/intro.html">11111111</a>
</ul>
<h2>Menu 2</h2>
<ul class="demos-list">
<li><a href="../demos/basic-single-column.html">222222222</a>
<li class="current"><a href="#content">3333333333</a></li>
</ul>
</nav> <!-- #site-nav -->
<section id="content">
<h1>cos tam ....</h1>
<div id="container" class="clearfix">
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// Retrieve all the data from the "test " table
$result = mysql_query("SELECT * FROM foto")
or die(mysql_error());
// store the records of the "TABLENAME" table into $row array and loop through
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
// Print out the contents of the entry
//echo "details: ".$row['id'];
echo '<div class="box photo col3">';
echo "<img src=\"".$row['src']."\" alt=\"wwwwww\" />";
echo '</div>';
}
?>
</div> <!-- #container -->
<script src="./js/jquery-1.7.1.min.js"></script>
<script src="./jquery.masonry.min.js"></script>
<script>
$(function(){
var $container = $('#container');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.box'
});
});
});
</script>
<footer id="site-footer">
szaki <a href="http://desandro.com">sdfsdfdsfsdf</a>
</footer>
</section> <!-- #content -->
</body>
</html>