web/php
php + json
명품_체인지업
2020. 2. 8. 15:11
//header("Access-Control-Allow-Origin:*"); // cross domain
//header("Content-Type: application/json; charset=utf-8"); // text/html
include_once("db_connect.php");
$json_data = array();
$sql = "select * from company where tel<>'' order by name limit 10" ;
$result = mysqli_query($conn, $sql);
while($row= mysqli_fetch_array($result)){
array_push($json_data, array('id'=>$row['ID'],'name'=>$row['name '], 'tel'=>$row['tel']));
}
echo json_encode(array("result"=>$json_data), JSON_UNESCAPED_UNICODE); //한글
mysqli_free_result($json_data);
// echo json_encode(array("result"=>$json_data), JSON_PRETTY_PRINT + JSON_UNESCAPED_UNICODE);
// mysqli_free_result($json_data, JSON_PRETTY_PRINT + JSON_UNESCAPED_UNICODE);
include_once("db_close.php");