I have a line of code to convert data from database to JSON. The only problem is that the code I have seems to be dropping the first record. Any thoughts to why.
$return_arr = Array();
$query_qrySelect = "SELECT * FROM table";
$qrySelect = mysql_query($query_qrySelect, $database) or die(mysql_error());
$row_qrySelect = mysql_fetch_assoc($qrySelect);
$totalRows_qrySelect = mysql_num_rows($qrySelect);
while ($row = mysql_fetch_array($qrySelect, MYSQL_ASSOC)) {
array_push($return_arr,$row);
}
echo json_encode($return_arr);
This line:
$row_qrySelect = mysql_fetch_assoc($qrySelect);
is where you're "losing" your data.