I will be sending the array to java in order to populate a ListView, how do I get the following code to output an array?:
<?php
$user = 'root';
$pass = '';
$db = 'uopuser';
$con=mysqli_connect('localhost', $user, $pass, $db) or die('Unable to connect');
$statement = mysqli_prepare($con, 'SELECT * FROM society');
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $society_id, $name, $email, $description);
$society = array();
while(mysqli_stmt_fetch($statement)){
$society['society_id'] = $society_id;
$society['name'] = $name;
$society['email'] = $email;
$society['description'] = $description;
echo json_encode($society);
}
echo json_encode($society);
mysqli_stmt_close($statement);
mysqli_close($con);
?>
Rather than:
{"society_id":1,"name":"TestName1","email":"Test@email1","description":"TestDes1"}
{"society_id":2,"name":"TestName2","email":"Test@email2","description":"TestDes2"}
{"society_id":3,"name":"TestName3","email":"Test@email3","description":"TestDes3"}
I've looked about the internet before posting this but am seriously confused! Thanks to anyone in advance.