[原创]PHP转换数据库查询结果为json

[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]