Jump to content

Recommended Posts

Hi dear friends,

I hope u are all fine.

I want to make a next button for getting more data from mysql database.

For example:

$sql = mysql_query("SELECT * FROM table LIMIT 0,7");

It get 7 rows.For next data code is that.

 

$sql = mysql_query("SELECT * FROM table LIMIT 7,7");

I can i do that using ajax.

As you can see in many website like facebook,When you click on comment it give a limited

comment and when you click on more comment it give more and so on.In this proccess you can see

that the other content of page does not change.It means it can use ajax and how can I do that in ajax.

Please help me.Thanks.

You request the PHP page doing the query with the page number. You use this to multiply by the amount of items to show per page to get the current position.

 

(page 1 - 1) * 20 items = 0 start and 20 limit

(page 2 - 1) * 20 items = 20 start and 20 limit

 

If you set the limit as a variable, then you can change this by changing that one number any time in the future.

 

As far as Ajax goes. You can use the regular Ajax function or Jquery's post function, which are both found on this page.

http://api.jquery.com/jQuery.post/

 

You most likely want to use post so you can send the page number you're requesting, but you could also use $_GET if you really want. Just add it onto the page you're requesting. You could just use Jquery's .load function then.

 

Just serialize your data, send it to the page, and fill the div with the resulting data returned from the page you posted to.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.