I'm in the process of building an iOS app that uses a webservice for data. The webservice consists of PHP, MySQL database.
I've successfully managed to JSON encode the data returned, but the code I am using only seems to encode 1 row.
I wanted to get some advice on how to encode multiple rows?
Thanks.
<?php
$username = "root";
$password = "*******";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
//print "Connected to MySQL<br>";
$selected = mysql_select_db("newtest",$dbh)
or die("Could not select first_test");
$query = "SELECT * FROM MyGuests ";
$result=mysql_query($query);
echo json_encode(mysql_fetch_assoc($result));
?>