javascript - JSON encode problems php -
javascript - JSON encode problems php -
what wrong way encoded?
<?php include ("../includes/db_con.php"); $itemresults = mysql_query("select `sold_for` `items` `item_did_sell`='1'") or die(); $miresults = mysql_query("select `mi_price`, `mi_total_sold` `misc_items` `mi_total_sold`>'1'") or die(); $donationresults = mysql_query("select `amount` `donations`") or die(mysql_error()); $total = 0; $itemtotal = 0; $mitotal = 0; $donationtotal = 0; while($row = mysql_fetch_assoc($itemresults)){ $itemtotal += $row['sold_for']; $total += $itemtotal; } while($row = mysql_fetch_assoc($miresults)){ $mitotal += ($row['mi_price'] * $row['mi_total_sold']); $total += $mitotal; } while($row = mysql_fetch_assoc($donationresults)){ $donationtotal += $row['amount']; $total += $donationtotal; } header("content-type: application/json"); $arr = array('items' => $itemtotal,'mitems' => $mitotal,'donations' => $donationtotal,'total' => $total); $arr = json_encode($arr); echo $arr; include ("../includes/db_discon.php"); ?>
the script outputs: {"items":1000,"mitems":0,"donations":0,"total":1000}
occurring client side javascript (which has been verified) there parase error in json array.
http://www.jquery4u.com/json/ajaxjquery-getjson-simple/
php javascript ajax json
Comments
Post a Comment