Right, it seems that you are calling mysqli_free_result() inside the fetch loop, so after the first iteration of the loop, your result resource has been closed and freed, and there will be no more results.
while($articles_info = mysqli_fetch_array($articles_data)) { $json = array(); $json['streamitem_id'] = $articles_info['streamitem_id']; $json['streamitem_content'] = $articles_info['streamitem_content']; $json['streamitem_timestamp'] = $articles_info['streamitem_timestamp'];
I note that you are calling mysqli_fetch_array() without specifying MYSQLI_ASSOC , and therefore you are returning both numeric and associative keys. If you use everything in your JSON, you do not need to perform all these assignments if you use MYSQLI_ASSOC or mysqli_fetch_assoc() :
while($articles_info = mysqli_fetch_assoc($articles_data)) { // No need for the $json array. Just use $articles_info directly // if you were going to json_encode() it. }
source share