php json_编码mysql结果

php json_编码mysql结果,php,mysql,json,Php,Mysql,Json,我有一个简单的mysql\u查询,我想用json编码结果(title=>$title,price=>$price等) $sql = mysql_query("SELECT * FROM item_details WHERE posting_id='$item_number'"); while($row = mysql_fetch_array($sql)) { $title = base64_decode($row['title']); $price = $row['price']

我有一个简单的
mysql\u查询
,我想用json编码
结果(title=>$title,price=>$price等)

$sql = mysql_query("SELECT * FROM item_details WHERE posting_id='$item_number'"); while($row = mysql_fetch_array($sql)) { $title = base64_decode($row['title']); $price = $row['price']; $seller_user = $row['user']; } $sql=mysql\u查询(“从项目详细信息中选择*,其中发布的项目id='$item\u number'”); while($row=mysql\u fetch\u数组($sql)) { $title=base64_解码($row['title']); $price=$row['price']; $seller_user=$row['user']; }
$sql = mysql_query("SELECT * FROM item_details WHERE posting_id='$item_number'");
$results = array();
while($row = mysql_fetch_array($sql))
{
   $results[] = array(
      'title' => base64_decode($row['title']),
      'price' => $row['price'],
      'seller_user' => $row['user']
   );
}
$json = json_encode($results);