<?php

$con = mysql_connect("localhost", "아이디", "비밀번호");



// 쿼리 전에 utf8로 셋팅

mysql_query("set names utf8",$con);

if (!$con)

{

  die('연결안됨: '.mysql_error());

} else {

  // 해당 DB select

  mysql_select_db("bonbebe",$con);

  

}




$return_array = array();

// sql 쿼리문 작성

$sql = "SELECT * FROM `userinfo` ";

$result = mysql_query($sql);



// json_encode 함수를 쓰면 Web에서 한글이 제데로 표시가 안됨

$outp = "[";

while($rs = mysql_fetch_array($result, MYSQL_ASSOC)) {

    if ($outp != "[") {$outp .= ",";}

    $outp .= '{"id":"'  . $rs["id"] . '",';

    $outp .= '"pw":"'   . $rs["pw"]        . '",';

    $outp .= '"country":"'. $rs["country"]     . '"}'; 

}

$outp .="]";



mysql_close($con);

echo($outp);


?>


Posted by 모과이IT
,