Ik hoop dat dit je zal helpen. Je kunt het in php implementeren om meer actie te laden.
elke keer na het klikken op meer knop verschuiving en limiet wijzigen in mysql-query
INSERT INTO table2 SELECT * FROM table1 LIMIT 0, 25;
load more...
INSERT INTO table2 SELECT * FROM table1 LIMIT 25, 25;
load more...
INSERT INTO table2 SELECT * FROM table1 LIMIT 50, 25;
....
....
Volledige code.
1. Kopieer en plak de volgende code in page1.php
<div id='message'></div>
<a href='#' id='LoadMore' >Load More</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
type="text/javascript"></script>
<script>
$(function() {
var page = 1;
$("#LoadMore").click(function(){
$.ajax({
type:"GET",
url:"page2.php",
data:{page:page},
success: function(response) {
$("#message").append(response);
page++;
}
});
});
});
</script>
2.Kopieer de volgende code in page2.php
en verander mysql_server, mysql_user, mysql_password, database_name argument in de eerste twee regels
<?php
//set argument as your mysql server
$connect = mysql_connect("mysql_server","mysql_user","mysql_password");
mysql_select_db("database_name",$connect);
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$limit = 25;
$offset = ($page - 1) * $limit;
$sql = "INSERT INTO table2 SELECT * FROM table1 limit $offset, $limit";
mysql_query($sql);
$rows = mysql_affected_rows();
echo "$rows rows added to table2 from table1<br>";
?>
3.Voer page1.php uit in browser... en laad gegevens naar tabel2
Toont nu gegevens uit tabel2 zonder de pagina te vernieuwen zoals vereist (gebruiker2714387 zei in reactie)
4.Kopieer en plak de volgende code in page3.php
<table width="300" border="1" id='data_grid'></table>
<a href='javascript://' id='LoadMore' >Load More</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
type="text/javascript"></script>
<script>
$(function() {
var page = 1;
$("#LoadMore").click(function(){
$.ajax({
type:"GET",
url:"page4.php",
data:{page:page},
success: function(response) {
$("#data_grid").append(response);
page++;
}
});
});
});
</script>
4.Kopieer de volgende code in page4.php
<?php
//set argument as your mysql server
$connect = mysql_connect("mysql_server","mysql_user","mysql_password");
mysql_select_db("database_name",$connect);
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$limit = 25;
$offset = ($page - 1) * $limit;
$sql = "SELECT * FROM table2 limit $offset, $limit";
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
if($numRows>0) {
while($row = mysql_fetch_array($result)) {
//get field data and set to the following row
echo "<tr><td>field 1</td><td>field 2</td><td>field 3</td></tr>";
//edit row as you table data
}
} else {
echo "<tr><td colspan='3'> No more data </td></tr>";
}
exit;
?>
6.Voer page4.php uit in de browser