Is there anyway to control the limit of entries from a database using jquery.
I have the PHP Data.php
:
mysqli_query($con,"(select * from social order by id desc limit 30) order by id asc");
But I want to be able to edit the limit 30
and use $.get()
to request the php again on calling a click function in jquery. Is this possible?
The $.get()
:
$.get("Data.php", function (data3) {
$(".data").html(data3);
});
My code now looks like this:
Data.php
:
$limit_amt = mysqli_real_escape_string($_GET['limit']);
$result = mysqli_query($con,"(select * from social order by id desc limit ".$limit_amt.") order by id asc");
while($row = mysqli_fetch_array($result))
{
echo "<tr class='border_bottom'>";
echo "<th scope='col'>";
echo "<div align='left'><span class='name'>".$row['name']."</span></div><br />";
echo "<span class='text'>".$row['comunicate']."</span><br />";
echo "<div align='right'><span class='time'>".$row['date']."</span></div>";
echo "</th>";
echo "</tr>";
}
Index.php
:
$.get("Data.php",{ limit: 40}, function (data3) { .
$(".data").html(data3);
});