Jump to content

fetch data in a continuous manner

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
jwxie518

jwxie518

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,180 posts
So let say I want to build something similar to Google Reader, example below
Posted Image

Or you can think of GR as codecall forum, #php forum

Each row is the title of the thread (or or title of the entry from your blod, in GR)

I can use LIMIT 0, 10 to fetch a limit quantity of data from the table (row, in this case, the title of the thread).

So when a user click on "Show more", or base on Google Reader style, the users scroll down, the javascript will then interacts the script to fetch more.

What I need help with is, how to fetch 10 rows everytime.

So let say here is my own code
<?php
require_once('front/config_custom.php');
$find = mysql_query("SELECT * FROM `notes` ORDER BY id DESC LIMIT 0, 10");
echo '<ul>';
while($row = mysql_fetch_array($find)){
echo '<li>' . $row['content'] .'</li>';
}
echo '</ul>';
?>

This is the first time , when a user enter my page, this is the script I wrote.

Now, I want the users to either click on SHOW ME MORE, or scroll down the bar, to fetch older threads from the same table.

So each time I want to fetch

1st 0 - 10
2nd 11 - 21
3rd 22 - 32
4th 33 - 43
5th 44 - 54
and so on

How do I do this?
I want the script to do this, fetch 10 after every click, and must be the 10 after the previous state.

Thanks.

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
This is done by ajax calls in Google reader, i.e it fetches 10, then fetches another 10 and so on.

an php variation might be to show just 10, and if they click the link "show me more, you load 30 instead.. but that's not so cool...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
jwxie518

jwxie518

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,180 posts
oh yeah... i should look at the $.ajax method instead... i was trying to minimize the use of javascript but php