-4

I have an Android app that fetches huge amount of data from a Mysql server, i'm using php to fetch data.

Using Volley library for network request.

Suppose of i have 100 names I want my app to load data in modules like 10 at a time. once 10 names are loaded i need to send a request again to fetch the next 10 i.e from 11-20 and so on.

Cant find a solution anywhere.

StackOverflow u guys are my last Hope.

I need something this.

2 Answers2

0

Try this demo:

Suppose, total records are 100, so count would be 100 and page will be 100/10 = 10. So first time call $page = 1. So first 10 records will be in response. second time $page = 2, so from 11-20 records will be there.. page count is from application side.

<?php
function test($page)
{
    if($page == '') {
        $page = 1;
    }
    if($page == 1)
    {
        $start = 0;
        $end = 10;
    }
    else
    {
        $start = ($page-1)*10;
        $end = 10;
    }

    $query = "SELECT * FROM tbl_name LIMIT $start,$end";
    // further process with data.
}
?>
Pathik Vejani
  • 4,263
  • 8
  • 57
  • 98
0

This may help you.

<?php
function test($start,$limit)
{
    
    $query = "SELECT * FROM tbl_name LIMIT $start,$limit";
    // further process with data.
}

for($i=0;$i<100;$i=$i+10){
test($i,10);
}
?>
Ananta Prasad
  • 3,655
  • 3
  • 23
  • 35