php json 인코딩

octopus7(50)
Published in
#kr
Words
0
Reading
0 min
Listen
Play
8y

https://stackoverflow.com/questions/383631/json-encode-mysql-results

$sth = mysqli_query("SELECT ...");
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
    $rows[] = $r;
}
print json_encode($rows);