I have a pagination that load more when I click on the load more button, which I got from the below URL http://makitweb.com/load-more-results-with-jqueryajax-and-php/
Whenever I add RAND() it always duplicates the value.
index.php
getData.php
Whenever I add RAND() it always duplicates the value.
index.php
Code:
<?php
$rowperpage = 10;
$allcount_query = "SELECT count(*) as allcount FROM users order by id";
$allcount_result = mysql_query($allcount_query);
$allcount_fetch = mysql_fetch_array($allcount_result);
$allcount = $allcount_fetch['allcount'];
$query = "select * from users order by RAND() asc limit 0,$rowperpage ";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
?>
<div><h1><?php echo $row['id']; ?></div>
<?php
}
?>
<h1 class="load-more">Load More</h1>
<input type="hidden" id="row" value="0">
<input type="hidden" id="all" value="<?php echo $allcount; ?>">
getData.php
Code:
<?php
$row = $_POST['row'];
$rowperpage = 10;
$query = 'SELECT * FROM users ORDER BY id limit '.$row.','.$rowperpage;
$result = mysql_query($query);
$html = '';
while($row = mysql_fetch_array($result)){
$html .= '<div><h1>'.$id.'</h1></div>';
}
?>
Comment