jquery - OnClick Function Get Next Record PHP AJAX MYSQL -
i getting stuck example found on topic. see original article: how show next result in mysql on "onclick" in javascript?
i followed example t, exception of using updated functions. anyway, getting stuck on 1 step, hoping explain.
within jquery below, code setting $number , passing number in post action php file. problem is when echo 'count', echos "$number". not sure why not passing actual number such "0" rather string "$number". doing wrong, not sure going on.
jquery
$(function(){ $('#showmore').click(function(event) { event.preventdefault(); $number = $('.result').size(); $.ajax({ type: "post", url: "getnext.php", data: "count=$number", success: function(results){ $('#results').append(results); } }); }); php
passing count variable can use in query, so:
$pst = $_post['count']; sql
$sql = "select * tablename limit $pst,1"; i went ahead , captured error receiving (see below) - mentioned inserting "$number" instead of actual number.
"fatal error: query failed! sql: select * tablename limit $number,1
any appreciated
problem sending count string $number in case.
your data should be
data: {"count":$number}, //notice `"` send object.
or
$data:"count=" + $number, concate var
i prefer data object more readable.
Comments
Post a Comment