Saya harap ini akan membantu Anda. Anda dapat mengimplementasikannya di php untuk memuat lebih banyak tindakan.
setiap kali setelah mengklik tombol lainnya, ubah offset dan batas dalam kueri mysql
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;
....
....
Kode lengkap.
1. Cukup salin dan tempel kode berikut di halaman1.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.Copy kode berikut di page2.php
dan ubah argumen mysql_server, mysql_user, mysql_password, database_name di dua baris pertama
<?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.Jalankan page1.php di browser... dan muat data ke table2
Sekarang menampilkan data dari table2 tanpa menyegarkan halaman seperti yang diperlukan (pengguna2714387 mengatakan dalam komentar)
4.Copy dan paste kode berikut di 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.Copy kode berikut di 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.Jalankan page4.php di browser