fetch_assoc()) { $comments[$index]["id"] = $record["id"]; $comments[$index]["comment"] = $record["comment"]; $comments[$index]["collaborator"] = $record["collaborator"]; $comments[$index]["name"] = $record["name"]; $comments[$index]["date"] = $record["date"]; // Increment index $index++; } mysqli_free_result($recordSet); echo(json_encode($comments)); // Close the connection to the database db_close($database); } catch(Exception $e) { $errorMsg = $e->getMessage(); print_r($errorMsg); } ?>