self.closest("#showtopicsAll").find("#showtopics").load(location.href + " #showtopics>*", "");SELECT
ft.date AS ftDate ,
ft.title AS ftTitle ,
ft.summary AS ftSummary ,
ft.randomString AS ftRandomString ,
u.username AS uUsername
FROM
forumtopic AS ft
LEFT JOIN
userlogininfo AS u
ON u.id = ft.userID
WHERE
categoryID = ?
ORDER BY
ft.date DESC
LIMIT ?<?php
getForumTopic ($pdo, $_GET['forumcategory'], 10); // starts out limit 10
?>
.
.
.
<div id="showtopicsAll">
.
.
.
<div id="showtopics">
// Loop through the found topics using the values from the session cookies set in getForumTopic to populate the page
<div class="show-more-topic">
<input type="hidden" id="categoryID" name="categoryID" value="<?php echo $_GET['forumcategory']; ?>">
<input type="hidden" id="topicCount" name="topicCount" value="<?php number of found topics in getForumTopic ?>">
<button id="showMoreTopic">
</button>
</div>
</div>
</div>$(document).ready(function(){
"use strict";
$(document).on('click','button[id^="showMoreTopic"]', function(){
var self = $(this);
var closestDiv = self.closest('.show-more-topic');
var topicCount = closestDiv.find("#topicCount").val();
var categoryID = closestDiv.find("#categoryID").val();
var topicCountNew = + topicCount + 10;
$.ajax({
type: "POST",
url:'../scripts/moretopic.php',
data:"topicCountNew="+topicCountNew+"&categoryID="+categoryID,
success:function(){
self.closest("#showtopicsAll").find("#showtopics").load(location.href + " #showtopics>*", "");
}
});
});
});session_start ();
require ( "../scripts/definitions.php" ); // holds some definitions needed for functions.php to work
require ( "../scripts/functions.php" ); // holds the getForumTopic function + the coection script for $pdo
$categoryID = $_POST['categoryID'];
$limit = $_POST['topicCountNew'];
getForumTopic ( $pdo , $categoryID , $limit ); // repopulates the session cookie now with 20 topics, 30 topics, 40... until no more so they are ready when the div is refreshedif (isset($_SESSION['countTopic_getForumTopic'])) {
$limit = $_SESSION['countTopic_getForumTopic'];
} else {
$limit = 10;
}getForumTopic ($pdo, $_GET['forumcategory'], $limit);self.closest("#showtopicsAll").find("#showtopics").load(location.href + " #showtopics>*", "");
برچسب:
نویسنده: آیلین رضوانی