Give me a thousand statistics through curl json, how can I divide the front end?

Suppose I send me a thousand statistics directly via curl, via json
, but it doesn"t seem right to show a thousand dollars at a time. How to achieve a 20-year-old through php? Is there anything you can refer to? Blah, blah, blah!

not at all

function httpRequest ($api, $data_string)
{
  $ch = curl_init($api);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
  curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  $result = curl_exec($ch);

  curl_close($ch);

  return json_decode($result);
}


$x = array(
      "session" => $_SESSION["session"]
    );
    $x_string = json_encode($x);
    $x = httpRequest($api, $x_string);

this is how I get the data of the opposite party, but how. Do the sharing?

Mar.02,2021

there is a problem with the design of the other side's interface. Is there no such parameter as page number or time?


the design of the API for this problem should be considerate. Paging should be given to the backend. If the backend does not support it, the front end cannot obtain only one page of data at a time. The back end can add paging support, and the front end < del > specifies the page number through < / del > through query string .


there are more than a thousand pages in the backend, but don't you do paging at the back end? I have more than 20 backends here to do paging


in theory, paging is handled by interfaces, and a thousand pieces of data at a time are not reasonable

the easiest way is to request the interface with two more parameters: offset,count
offset is the value of the current page number, and count is the amount of data to be displayed on each page

after receiving these two parameters, the backend calculates the starting position of each requested data in the database
eg:

//$offset $count 
$a = ($offset-1)*$count;
// limit $a,$count

as mentioned upstairs, so much data paging should be handled by the back end
if you say the front end is js, then you can for-of it

.
function *paginate(data, offset, limit) {
   for(var i = offset; i<=offset + limit; iPP) {
     yield data[i];
   }
}

() 1000 pages are not paged yet?
in theory, paging is done by the backend. A basic idea is: the
front end needs to send the current number of pages to the back end, the amount of data per page; the
back end returns the current page data to the front end, the total number of data items.
the front end needs to make corresponding page number links according to the total amount of data and the number of pages per page.


if the data fetched is the same, then the backend regularly acquires the storage cache, and then you query the page and page it to the front end

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32d56-2be42.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32d56-2be42.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?