1
I have a query that returns the data below:
nome -------- vencimento
Joao -------- 09/08/2012
Maria ------- 04/12/2015
That is to say, two records.
However, by putting it in PHP code only the top record is returned, even using +=
and a structure while
in the 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 current $result:
{"nome":"Joao","vencimento":"09/08/2012"}
Expected return $result:
{"nome":"Joao","vencimento":"09/08/2012"}
{"nome":"Maria","vencimento":"04/12/2015"}
It worked @rray, but you can tell me why it happens?
– Lucas Torres