I want display data from mysql database like [Youtube][1] comment 10 comments ‘show more 10’ link … how I can get this ?
That is my code
$entities = mysql_query(“SELECT timestamp, username, message FROM comments WHERE page_name = ‘$message_page’ ORDER BY timestamp DESC”);
if (mysql_num_rows($entities) ==0) {
echo '<strong>No comment, yet.</strong>';
} else {
while ($entities_row = mysql_fetch_assoc($entities)) {
$entities_timestamp = $entities_row['timestamp'];
$entities_username = $entities_row['username'];
$entities_message = $entities_row['message'];
}
What query are you trying ?What have achieved so far?Mention it and it would be easy for others to help you!
As far as your question goes,you will have to use
limitin your SQL query and on click of show more will need to get the next batch of records using ajaxHere,offset would be the starting point and limit would be the no of records to get.
So,your offset first time would be 0 and limit would be 10.
Next iteration(on clicking show more) it will be 10,10
next 20,10 and so on
your jquery function would look like this
Hope it helps 🙂
Update
SELECT timestamp, username, message FROM comments WHERE page_name = '$message_page' ORDER BY timestamp DESC limit 0,10Here,0 is the offset and 10 is the limit.This will get the first 10 records of returned by the query.Now you will have to increment your offset by the value of the limit,so do it like–>
offset = offset+limit;(initialize offset to 0 first)Now next iteration your offset would be 10 and limit will remain 10 as you need to get 10 records at a time.Call the ajax function on click of your show more link.This should be it.