im doing something where users has a local database and when he clicks to checks new books, it get all the IDS(fixed) form his local database and create String separeted by comma (1,2,3,4,5) and then do a GET to my server
www.myserver.com/getNews?ids=1,2,4,10
and in the server side i do this:
1) Get the last ID(fixed) and set in a var called $total
2) get the IDS send by the user and create a array using .explode(",")
3) get the missing values $missing = array_diff(range(1,$total),$ids);
get max id and get the missing numbers between the $total
and $ids
and here come the part that i think its heavy:
for each $missing
value i do a select and build a array to display as json
foreach($missing as $m) {
$sql = "SELECT * FROM `books` WHERE id='$m'";
while($row =mysqli_fetch_assoc($result))
{
$emparray[] = array_map('utf8_encode', $row);
}
}
echo json_encode($emparray);
this is the only one approach or is there any other more light function?