【发布时间】:2015-01-17 21:58:53
【问题描述】:
我在 joomla 3 中有一篇文章,其中包含这样的 php 代码:
<?php
include(config.php);
$limit = 10; #item per page
# db connect
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to MySQL DB ') . mysql_error();
$db = mysql_select_db(DB_NAME, $link);
$page = (int) (!isset($_GET['p'])) ? 1 : $_GET['p'];
# sql query
$sql = "SELECT * FROM actor_info ORDER BY id DESC";
# find out query stat point
$start = ($page * $limit) - $limit;
# query for page navigation
if( mysql_num_rows(mysql_query($sql)) > ($page * $limit) ){
$next = ++$page;
}
$query = mysql_query( $sql . " LIMIT {$start}, {$limit}");
if (mysql_num_rows($query) < 1) {
header('HTTP/1.0 404 Not Found');
echo 'Page not found!';
exit();
}
?>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://localhost/test/js/js/jquery-ias.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Infinite Ajax Scroll configuration
jQuery.ias({
container : '#content', // main container where data goes to append
item: ".post",
pagination: "#content .navigation a",
next: ".next-posts a",
loader: '<img src="css/ajax-loader.gif"/>', // loading gif
triggerPageThreshold: 3 // show load more if scroll more than this
});
});
</script>
</head>
<body>
<div class="wrap">
<h1><a href="#">Data load while scroll</a></h1>
<!-- loop row data -->
<?php while ($row = mysql_fetch_array($query)): ?>
<div class="item" id="item-<?php echo $row['id']?>">
<h2>
<span class="num"><?php echo $row['id']?></span>
<span class="name"><?php echo $row['first_name'].' '.$row['last_name']?></span>
</h2>
<p><?php echo $row['film_info']?></p>
</div>
<?php endwhile?>
<!--page navigation-->
<?php if (isset($next)): ?>
<div class="nav">
<div class="next-posts"><a href='test?p=<?php echo $next?>'>Next</a></div>
</div>
<?php endif?>
</div><!--.wrap-->
</body>
</html>
现在它可以从数据库中检索数据,但是当我想获得滚动效果时,它会停止……所以它出现了一个链接“NEXT”,将我带到下一页 /test?p=2 等等
我该如何解决?
我通过一个名为 SOURCERER 的插件将这段代码放在一篇文章中
【问题讨论】:
标签: php jquery css joomla pagination