[原创]PHP转换数据库查询结果为json
- PHP
- 2014-03-13
- 101热度
- 0评论
[php]
include 'db.php';
$sql='select * from kw_projects';
$result=mysql_query($sql);
$results = array();
while ( $row = mysql_fetch_assoc( $result )) {
$results[] = $row;
}
echo json_encode( $results );
[/php]