PHP fetching same records again and again












-1















NOTE: Please don't mark my question duplicate.



I am trying to fetch new records while "Load More" button is pressed.



The problem I am facing here is that I am unable to change the values of $Limit and $offset variables and as a result, the same records are being fetched again and again.



HTML Code:



<body>
<nav>
<h1 id="h1Nav">Myheading</h1>
<ul>
<li><a onclick="window.location('Home.html');" href="">Home</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Info</a></li>
</ul>
</nav>
<section id="contentSection">
</section>
<button name="LOAD_MORE_REQUEST" value="loadMoreButton" onclick="loadContent();" id="LoadMoreButton">Load more
</button>

<section id="footerSection">
<form action="">
<p>Enter You email adress and get notified:-</p>
<input type="email" id="footerEmailInput" name="footerEmailInputField" placeholder="Please enter yor email...">
<input type="submit" id="submitFooterEmailInputFieldSubmitButton" name="submitFooterEmailInputField">
</form>
<div id="linksDivFooterSection">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Privacy</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</div>
</section>
<script src="Home.js" type="text/javascript"></script>
</body>

</html>


JS code:



function loadContent(){
var loadMoreButton = document.getElementById("LoadMoreButton").value;
var sendLoadContentRequest = new XMLHttpRequest();
requestQuery_Data = new FormData();
requestQuery_Data.append("LOAD_MORE_REQUEST", loadMoreButton);
sendLoadContentRequest.open("POST", "LoadContent.php", true);
sendLoadContentRequest.send(requestQuery_Data);
DefaultText = document.getElementById("contentSection").innerHTML;
sendLoadContentRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("contentSection").innerHTML = DefaultText + sendLoadContentRequest.responseText;
}
}
}
window.onload = loadContent();


Here is my PHP code:



require("connection.php");

ini_set('display_errors', 'On'); //to get errors displayed
error_reporting(E_ALL); // to kep errors on

if(isset($_POST["LOAD_MORE_REQUEST"])){
loadContentOnPage();
}
else{
echo("Error");
}

function loadContentOnPage()
{
global $offset;
global $Limit;

if(isset($_POST['Offset_Field_Request'])) {
echo($offset);
echo($Limit);
$offset = $offset + 2;
$Limit = $Limit + 0;
}

global $Preview_img;
global $myconnection;
global $Tag1;
global $Tag2;
global $Tag3;
global $Tag4;

$retriveQuery_Article = "SELECT ArticleTitle, PreviewText, PreviewImage FROM Articles ORDER BY ID DESC LIMIT $Limit, $offset";
$query_run = mysqli_query($myconnection, $retriveQuery_Article);


if(!$query_run){
echo("Error.... " . mysqli_error($myconnection));
}

while($result_Article = mysqli_fetch_assoc($query_run)) {
$Article_Title = $result_Article['ArticleTitle'];
$Article_PreviewText = $result_Article['PreviewText'];
$Article_PreviewImg = $result_Article['PreviewImage'];
$retriveQuery_Img = "SELECT imagePath, tag1, tag2, tag3, tag4 FROM image WHERE name='$Article_PreviewImg'";
$query_run_img = mysqli_query($myconnection, $retriveQuery_Img);
if(!$query_run_img){ echo("Again error.... " . mysqli_error($myconnection)); }
while($result_img = mysqli_fetch_assoc($query_run_img)){
$Tag1 = $result_img['tag1'];
$Tag2 = $result_img['tag2'];
$Tag3 = $result_img['tag3'];
$Tag4 = $result_img['tag4'];
}


$response = '
<section class="ArticleSection1">
<div class="imageDivArticleSection1">
<img src="' . $Preview_img . '"></img>
</div>
<div class="PreviewTextDiv">
<h1>' . $Article_Title . '</h1>
<br>
<p> '
. $Article_PreviewText .
'</p>
<br>
<button>Read more</button>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag1 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag2 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag3 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag4 . '</a></span>
</div>
</section>
';

echo($response);
}
}









share|improve this question

























  • When you echo the $offset before and after the +2 it gives you the same result? where the $offset is originally declare?

    – dWinder
    Nov 27 '18 at 7:40











  • What is your while loop doing? I guess there should be == to check condition.

    – Prashant Deshmukh.....
    Nov 27 '18 at 7:43






  • 1





    You seem to use global quite a bit, generally I would discourage this unless you really need to. Passing parameters to a function makes it more flexible and testable.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • @PrashantDeshmukh..... this is fetching a row from the database, so assignment is correct.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • Have a read of stackoverflow.com/questions/3705318/…

    – Nigel Ren
    Nov 27 '18 at 7:54
















-1















NOTE: Please don't mark my question duplicate.



I am trying to fetch new records while "Load More" button is pressed.



The problem I am facing here is that I am unable to change the values of $Limit and $offset variables and as a result, the same records are being fetched again and again.



HTML Code:



<body>
<nav>
<h1 id="h1Nav">Myheading</h1>
<ul>
<li><a onclick="window.location('Home.html');" href="">Home</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Info</a></li>
</ul>
</nav>
<section id="contentSection">
</section>
<button name="LOAD_MORE_REQUEST" value="loadMoreButton" onclick="loadContent();" id="LoadMoreButton">Load more
</button>

<section id="footerSection">
<form action="">
<p>Enter You email adress and get notified:-</p>
<input type="email" id="footerEmailInput" name="footerEmailInputField" placeholder="Please enter yor email...">
<input type="submit" id="submitFooterEmailInputFieldSubmitButton" name="submitFooterEmailInputField">
</form>
<div id="linksDivFooterSection">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Privacy</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</div>
</section>
<script src="Home.js" type="text/javascript"></script>
</body>

</html>


JS code:



function loadContent(){
var loadMoreButton = document.getElementById("LoadMoreButton").value;
var sendLoadContentRequest = new XMLHttpRequest();
requestQuery_Data = new FormData();
requestQuery_Data.append("LOAD_MORE_REQUEST", loadMoreButton);
sendLoadContentRequest.open("POST", "LoadContent.php", true);
sendLoadContentRequest.send(requestQuery_Data);
DefaultText = document.getElementById("contentSection").innerHTML;
sendLoadContentRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("contentSection").innerHTML = DefaultText + sendLoadContentRequest.responseText;
}
}
}
window.onload = loadContent();


Here is my PHP code:



require("connection.php");

ini_set('display_errors', 'On'); //to get errors displayed
error_reporting(E_ALL); // to kep errors on

if(isset($_POST["LOAD_MORE_REQUEST"])){
loadContentOnPage();
}
else{
echo("Error");
}

function loadContentOnPage()
{
global $offset;
global $Limit;

if(isset($_POST['Offset_Field_Request'])) {
echo($offset);
echo($Limit);
$offset = $offset + 2;
$Limit = $Limit + 0;
}

global $Preview_img;
global $myconnection;
global $Tag1;
global $Tag2;
global $Tag3;
global $Tag4;

$retriveQuery_Article = "SELECT ArticleTitle, PreviewText, PreviewImage FROM Articles ORDER BY ID DESC LIMIT $Limit, $offset";
$query_run = mysqli_query($myconnection, $retriveQuery_Article);


if(!$query_run){
echo("Error.... " . mysqli_error($myconnection));
}

while($result_Article = mysqli_fetch_assoc($query_run)) {
$Article_Title = $result_Article['ArticleTitle'];
$Article_PreviewText = $result_Article['PreviewText'];
$Article_PreviewImg = $result_Article['PreviewImage'];
$retriveQuery_Img = "SELECT imagePath, tag1, tag2, tag3, tag4 FROM image WHERE name='$Article_PreviewImg'";
$query_run_img = mysqli_query($myconnection, $retriveQuery_Img);
if(!$query_run_img){ echo("Again error.... " . mysqli_error($myconnection)); }
while($result_img = mysqli_fetch_assoc($query_run_img)){
$Tag1 = $result_img['tag1'];
$Tag2 = $result_img['tag2'];
$Tag3 = $result_img['tag3'];
$Tag4 = $result_img['tag4'];
}


$response = '
<section class="ArticleSection1">
<div class="imageDivArticleSection1">
<img src="' . $Preview_img . '"></img>
</div>
<div class="PreviewTextDiv">
<h1>' . $Article_Title . '</h1>
<br>
<p> '
. $Article_PreviewText .
'</p>
<br>
<button>Read more</button>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag1 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag2 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag3 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag4 . '</a></span>
</div>
</section>
';

echo($response);
}
}









share|improve this question

























  • When you echo the $offset before and after the +2 it gives you the same result? where the $offset is originally declare?

    – dWinder
    Nov 27 '18 at 7:40











  • What is your while loop doing? I guess there should be == to check condition.

    – Prashant Deshmukh.....
    Nov 27 '18 at 7:43






  • 1





    You seem to use global quite a bit, generally I would discourage this unless you really need to. Passing parameters to a function makes it more flexible and testable.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • @PrashantDeshmukh..... this is fetching a row from the database, so assignment is correct.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • Have a read of stackoverflow.com/questions/3705318/…

    – Nigel Ren
    Nov 27 '18 at 7:54














-1












-1








-1








NOTE: Please don't mark my question duplicate.



I am trying to fetch new records while "Load More" button is pressed.



The problem I am facing here is that I am unable to change the values of $Limit and $offset variables and as a result, the same records are being fetched again and again.



HTML Code:



<body>
<nav>
<h1 id="h1Nav">Myheading</h1>
<ul>
<li><a onclick="window.location('Home.html');" href="">Home</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Info</a></li>
</ul>
</nav>
<section id="contentSection">
</section>
<button name="LOAD_MORE_REQUEST" value="loadMoreButton" onclick="loadContent();" id="LoadMoreButton">Load more
</button>

<section id="footerSection">
<form action="">
<p>Enter You email adress and get notified:-</p>
<input type="email" id="footerEmailInput" name="footerEmailInputField" placeholder="Please enter yor email...">
<input type="submit" id="submitFooterEmailInputFieldSubmitButton" name="submitFooterEmailInputField">
</form>
<div id="linksDivFooterSection">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Privacy</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</div>
</section>
<script src="Home.js" type="text/javascript"></script>
</body>

</html>


JS code:



function loadContent(){
var loadMoreButton = document.getElementById("LoadMoreButton").value;
var sendLoadContentRequest = new XMLHttpRequest();
requestQuery_Data = new FormData();
requestQuery_Data.append("LOAD_MORE_REQUEST", loadMoreButton);
sendLoadContentRequest.open("POST", "LoadContent.php", true);
sendLoadContentRequest.send(requestQuery_Data);
DefaultText = document.getElementById("contentSection").innerHTML;
sendLoadContentRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("contentSection").innerHTML = DefaultText + sendLoadContentRequest.responseText;
}
}
}
window.onload = loadContent();


Here is my PHP code:



require("connection.php");

ini_set('display_errors', 'On'); //to get errors displayed
error_reporting(E_ALL); // to kep errors on

if(isset($_POST["LOAD_MORE_REQUEST"])){
loadContentOnPage();
}
else{
echo("Error");
}

function loadContentOnPage()
{
global $offset;
global $Limit;

if(isset($_POST['Offset_Field_Request'])) {
echo($offset);
echo($Limit);
$offset = $offset + 2;
$Limit = $Limit + 0;
}

global $Preview_img;
global $myconnection;
global $Tag1;
global $Tag2;
global $Tag3;
global $Tag4;

$retriveQuery_Article = "SELECT ArticleTitle, PreviewText, PreviewImage FROM Articles ORDER BY ID DESC LIMIT $Limit, $offset";
$query_run = mysqli_query($myconnection, $retriveQuery_Article);


if(!$query_run){
echo("Error.... " . mysqli_error($myconnection));
}

while($result_Article = mysqli_fetch_assoc($query_run)) {
$Article_Title = $result_Article['ArticleTitle'];
$Article_PreviewText = $result_Article['PreviewText'];
$Article_PreviewImg = $result_Article['PreviewImage'];
$retriveQuery_Img = "SELECT imagePath, tag1, tag2, tag3, tag4 FROM image WHERE name='$Article_PreviewImg'";
$query_run_img = mysqli_query($myconnection, $retriveQuery_Img);
if(!$query_run_img){ echo("Again error.... " . mysqli_error($myconnection)); }
while($result_img = mysqli_fetch_assoc($query_run_img)){
$Tag1 = $result_img['tag1'];
$Tag2 = $result_img['tag2'];
$Tag3 = $result_img['tag3'];
$Tag4 = $result_img['tag4'];
}


$response = '
<section class="ArticleSection1">
<div class="imageDivArticleSection1">
<img src="' . $Preview_img . '"></img>
</div>
<div class="PreviewTextDiv">
<h1>' . $Article_Title . '</h1>
<br>
<p> '
. $Article_PreviewText .
'</p>
<br>
<button>Read more</button>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag1 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag2 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag3 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag4 . '</a></span>
</div>
</section>
';

echo($response);
}
}









share|improve this question
















NOTE: Please don't mark my question duplicate.



I am trying to fetch new records while "Load More" button is pressed.



The problem I am facing here is that I am unable to change the values of $Limit and $offset variables and as a result, the same records are being fetched again and again.



HTML Code:



<body>
<nav>
<h1 id="h1Nav">Myheading</h1>
<ul>
<li><a onclick="window.location('Home.html');" href="">Home</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Info</a></li>
</ul>
</nav>
<section id="contentSection">
</section>
<button name="LOAD_MORE_REQUEST" value="loadMoreButton" onclick="loadContent();" id="LoadMoreButton">Load more
</button>

<section id="footerSection">
<form action="">
<p>Enter You email adress and get notified:-</p>
<input type="email" id="footerEmailInput" name="footerEmailInputField" placeholder="Please enter yor email...">
<input type="submit" id="submitFooterEmailInputFieldSubmitButton" name="submitFooterEmailInputField">
</form>
<div id="linksDivFooterSection">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Privacy</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</div>
</section>
<script src="Home.js" type="text/javascript"></script>
</body>

</html>


JS code:



function loadContent(){
var loadMoreButton = document.getElementById("LoadMoreButton").value;
var sendLoadContentRequest = new XMLHttpRequest();
requestQuery_Data = new FormData();
requestQuery_Data.append("LOAD_MORE_REQUEST", loadMoreButton);
sendLoadContentRequest.open("POST", "LoadContent.php", true);
sendLoadContentRequest.send(requestQuery_Data);
DefaultText = document.getElementById("contentSection").innerHTML;
sendLoadContentRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("contentSection").innerHTML = DefaultText + sendLoadContentRequest.responseText;
}
}
}
window.onload = loadContent();


Here is my PHP code:



require("connection.php");

ini_set('display_errors', 'On'); //to get errors displayed
error_reporting(E_ALL); // to kep errors on

if(isset($_POST["LOAD_MORE_REQUEST"])){
loadContentOnPage();
}
else{
echo("Error");
}

function loadContentOnPage()
{
global $offset;
global $Limit;

if(isset($_POST['Offset_Field_Request'])) {
echo($offset);
echo($Limit);
$offset = $offset + 2;
$Limit = $Limit + 0;
}

global $Preview_img;
global $myconnection;
global $Tag1;
global $Tag2;
global $Tag3;
global $Tag4;

$retriveQuery_Article = "SELECT ArticleTitle, PreviewText, PreviewImage FROM Articles ORDER BY ID DESC LIMIT $Limit, $offset";
$query_run = mysqli_query($myconnection, $retriveQuery_Article);


if(!$query_run){
echo("Error.... " . mysqli_error($myconnection));
}

while($result_Article = mysqli_fetch_assoc($query_run)) {
$Article_Title = $result_Article['ArticleTitle'];
$Article_PreviewText = $result_Article['PreviewText'];
$Article_PreviewImg = $result_Article['PreviewImage'];
$retriveQuery_Img = "SELECT imagePath, tag1, tag2, tag3, tag4 FROM image WHERE name='$Article_PreviewImg'";
$query_run_img = mysqli_query($myconnection, $retriveQuery_Img);
if(!$query_run_img){ echo("Again error.... " . mysqli_error($myconnection)); }
while($result_img = mysqli_fetch_assoc($query_run_img)){
$Tag1 = $result_img['tag1'];
$Tag2 = $result_img['tag2'];
$Tag3 = $result_img['tag3'];
$Tag4 = $result_img['tag4'];
}


$response = '
<section class="ArticleSection1">
<div class="imageDivArticleSection1">
<img src="' . $Preview_img . '"></img>
</div>
<div class="PreviewTextDiv">
<h1>' . $Article_Title . '</h1>
<br>
<p> '
. $Article_PreviewText .
'</p>
<br>
<button>Read more</button>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag1 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag2 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag3 . '</a></span>
<span class="TagSpan"><a class="TagLink"> Dev ' . $Tag4 . '</a></span>
</div>
</section>
';

echo($response);
}
}






javascript php mysql ajax






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 29 '18 at 5:35







Tech guy

















asked Nov 27 '18 at 7:34









Tech guyTech guy

134




134













  • When you echo the $offset before and after the +2 it gives you the same result? where the $offset is originally declare?

    – dWinder
    Nov 27 '18 at 7:40











  • What is your while loop doing? I guess there should be == to check condition.

    – Prashant Deshmukh.....
    Nov 27 '18 at 7:43






  • 1





    You seem to use global quite a bit, generally I would discourage this unless you really need to. Passing parameters to a function makes it more flexible and testable.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • @PrashantDeshmukh..... this is fetching a row from the database, so assignment is correct.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • Have a read of stackoverflow.com/questions/3705318/…

    – Nigel Ren
    Nov 27 '18 at 7:54



















  • When you echo the $offset before and after the +2 it gives you the same result? where the $offset is originally declare?

    – dWinder
    Nov 27 '18 at 7:40











  • What is your while loop doing? I guess there should be == to check condition.

    – Prashant Deshmukh.....
    Nov 27 '18 at 7:43






  • 1





    You seem to use global quite a bit, generally I would discourage this unless you really need to. Passing parameters to a function makes it more flexible and testable.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • @PrashantDeshmukh..... this is fetching a row from the database, so assignment is correct.

    – Nigel Ren
    Nov 27 '18 at 7:44











  • Have a read of stackoverflow.com/questions/3705318/…

    – Nigel Ren
    Nov 27 '18 at 7:54

















When you echo the $offset before and after the +2 it gives you the same result? where the $offset is originally declare?

– dWinder
Nov 27 '18 at 7:40





When you echo the $offset before and after the +2 it gives you the same result? where the $offset is originally declare?

– dWinder
Nov 27 '18 at 7:40













What is your while loop doing? I guess there should be == to check condition.

– Prashant Deshmukh.....
Nov 27 '18 at 7:43





What is your while loop doing? I guess there should be == to check condition.

– Prashant Deshmukh.....
Nov 27 '18 at 7:43




1




1





You seem to use global quite a bit, generally I would discourage this unless you really need to. Passing parameters to a function makes it more flexible and testable.

– Nigel Ren
Nov 27 '18 at 7:44





You seem to use global quite a bit, generally I would discourage this unless you really need to. Passing parameters to a function makes it more flexible and testable.

– Nigel Ren
Nov 27 '18 at 7:44













@PrashantDeshmukh..... this is fetching a row from the database, so assignment is correct.

– Nigel Ren
Nov 27 '18 at 7:44





@PrashantDeshmukh..... this is fetching a row from the database, so assignment is correct.

– Nigel Ren
Nov 27 '18 at 7:44













Have a read of stackoverflow.com/questions/3705318/…

– Nigel Ren
Nov 27 '18 at 7:54





Have a read of stackoverflow.com/questions/3705318/…

– Nigel Ren
Nov 27 '18 at 7:54












1 Answer
1






active

oldest

votes


















0














Sorry, but i didnt saw the line in your code, where you are trying to rewrite your variable $offset.



If you are sendeing ajax request for geting new rows, you sholud to send in post variables for checking offset.



e.x your request may containg GET &page=2



'PAGE' - number of loaded pages, which you are saving in JS on user side.



On the user side in JS u must have the variable 'var page = 1' and When user pressed button 'MORE' you have to send AJAX request with GET parameter 'page' and increasing by 1 your variable 'var page';



In you server side by php you geting url param 'page' and multiply it on your limit, so you u will get your offset.



I didn't wrote all points, but i hope it will help u.






share|improve this answer


























  • Is it possible using POST

    – Tech guy
    Nov 27 '18 at 13:42











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53494783%2fphp-fetching-same-records-again-and-again%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Sorry, but i didnt saw the line in your code, where you are trying to rewrite your variable $offset.



If you are sendeing ajax request for geting new rows, you sholud to send in post variables for checking offset.



e.x your request may containg GET &page=2



'PAGE' - number of loaded pages, which you are saving in JS on user side.



On the user side in JS u must have the variable 'var page = 1' and When user pressed button 'MORE' you have to send AJAX request with GET parameter 'page' and increasing by 1 your variable 'var page';



In you server side by php you geting url param 'page' and multiply it on your limit, so you u will get your offset.



I didn't wrote all points, but i hope it will help u.






share|improve this answer


























  • Is it possible using POST

    – Tech guy
    Nov 27 '18 at 13:42
















0














Sorry, but i didnt saw the line in your code, where you are trying to rewrite your variable $offset.



If you are sendeing ajax request for geting new rows, you sholud to send in post variables for checking offset.



e.x your request may containg GET &page=2



'PAGE' - number of loaded pages, which you are saving in JS on user side.



On the user side in JS u must have the variable 'var page = 1' and When user pressed button 'MORE' you have to send AJAX request with GET parameter 'page' and increasing by 1 your variable 'var page';



In you server side by php you geting url param 'page' and multiply it on your limit, so you u will get your offset.



I didn't wrote all points, but i hope it will help u.






share|improve this answer


























  • Is it possible using POST

    – Tech guy
    Nov 27 '18 at 13:42














0












0








0







Sorry, but i didnt saw the line in your code, where you are trying to rewrite your variable $offset.



If you are sendeing ajax request for geting new rows, you sholud to send in post variables for checking offset.



e.x your request may containg GET &page=2



'PAGE' - number of loaded pages, which you are saving in JS on user side.



On the user side in JS u must have the variable 'var page = 1' and When user pressed button 'MORE' you have to send AJAX request with GET parameter 'page' and increasing by 1 your variable 'var page';



In you server side by php you geting url param 'page' and multiply it on your limit, so you u will get your offset.



I didn't wrote all points, but i hope it will help u.






share|improve this answer















Sorry, but i didnt saw the line in your code, where you are trying to rewrite your variable $offset.



If you are sendeing ajax request for geting new rows, you sholud to send in post variables for checking offset.



e.x your request may containg GET &page=2



'PAGE' - number of loaded pages, which you are saving in JS on user side.



On the user side in JS u must have the variable 'var page = 1' and When user pressed button 'MORE' you have to send AJAX request with GET parameter 'page' and increasing by 1 your variable 'var page';



In you server side by php you geting url param 'page' and multiply it on your limit, so you u will get your offset.



I didn't wrote all points, but i hope it will help u.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 27 '18 at 8:03

























answered Nov 27 '18 at 7:58









user10685556user10685556

212




212













  • Is it possible using POST

    – Tech guy
    Nov 27 '18 at 13:42



















  • Is it possible using POST

    – Tech guy
    Nov 27 '18 at 13:42

















Is it possible using POST

– Tech guy
Nov 27 '18 at 13:42





Is it possible using POST

– Tech guy
Nov 27 '18 at 13:42




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53494783%2fphp-fetching-same-records-again-and-again%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)