Monday, April 18, 2016

SELECT the Data From The DB and parse to array and then to json for angular access

<?php

$con=mysqli_connect("localhost","root","","ang"); 
 
$query="SELECT * FROM user"; 
 
$res=mysqli_query($con,$query);
$arr=array();
    if($res->num_rows > 0){
        while($row = $res->fetch_assoc()){
            $arr[]=$row;
        }

    }
echo $json_response = json_encode($arr);

No comments:

Post a Comment