I have a query that returns the data below:
nome -------- vencimento
Joao -------- 09/08/2012
Maria ------- 04/12/2015
That is, two records .
However, by putting it in PHP code only the top record is returned, even using +=
and a while
structure in mysql_fetch_assoc
.
PHP Code
$result = array();
$sql_select = mysql_query(
"SELECT nome, vencimento
FROM alunos"
)or die(mysql_error());
while($l = mysql_fetch_assoc($sql_select)){
$result += $l;
}
return json_encode($result);
Return $ result current :
{"nome":"Joao","vencimento":"09/08/2012"}
Return $ expected result :
{"nome":"Joao","vencimento":"09/08/2012"}
{"nome":"Maria","vencimento":"04/12/2015"}