I have one table. Which name is student. There is three column.
Name Address Roll Age
X A 1 20
Y B 2 20
z C 3 20
M D 4 25
I want to collect all name and address whose Age is 20. I use this.
$sql = "select Name,Age from student where Age = 20";
while($data= sqlsrv_fetch_array($sql,SQLSRV_FETCH_ASSOC))
{
echo json_encode(data);
}
By this i get just last row data that means
{"Name":X,"Address":A}
But i want like this
{"Name":X,"Address":A,"Name":Y,"Address":B,"Name":Z,"Address":C}