2012年9月19日 星期三

PHP 取得DB資料使用JSON回給client

PHP 取得DB資料使用JSON回給client
並且讓數字不加引號
$sth = mysql_query("SELECT ...");

$rows = array();

while($r = mysql_fetch_assoc($sth))
{
    while($elm=each($r))
    {
        if(is_numeric($r[$elm["key"]])){
                    $r[$elm["key"]]=intval($r[$elm["key"]]);
        }
    }
    $rows[] = $r;
}  

沒有留言:

張貼留言