Contoh PHP Mysql ke Json

  Umum
<?php
$mysqli = new mysqli('localhost','mfahri','','db');
$myArray = array();
if ($result = $mysqli->query("SELECT * FROM `ambil_barang`")) {

    while($row = $result->fetch_array(MYSQLI_ASSOC)) {
            $myArray[] = $row;
    }
    echo json_encode($myArray);
}

$result->close();
$mysqli->close();


?>

LEAVE A COMMENT