关于复杂查询的结果如何转化JSON格式?
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM user WHERE username = '$username'
and password = '$password' ";
$aaa = mysql_query($sql);
if(mysql_num_rows($aaa)){
$rows = mysql_fetch_row($aaa);
echo "用户名:".$rows[0]."<br/>";
echo "密码:".$rows[1];
session_start();
$_SESSION['username'] = $rows[0];
}else{
echo "错误";
}
连接数据库查询完结果后如何使输出结果变成json格式?