$sth = mysqli_query($conn, "SELECT ...");
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
फ़ंक्शन json_encode PHP>=5.2 और php-json . की आवश्यकता है पैकेज - जैसा बताया गया है यहां
नोट :mysql PHP 5.5.0 के रूप में बहिष्कृत है, mysqli . का उपयोग करें इसके बजाय एक्सटेंशन https://php.net/manual/en/migration55.deprecated.php
।