码迷,mamicode.com
首页 > Web开发 > 详细

php json dom解析

时间:2015-09-02 18:51:51      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:

<script>

$(function(){


dataparam={"app_id":<?=$CYCLE_NO?>};
$.ajax({
type: ‘POST‘,
dataType: "json",
url: ‘ajax/getappinfo.php‘,
cache: false,
data:dataparam,
success: function(data)
{
$.each(data,function(idx,item){
var pro_id=item.PRO_ID;
// $("#pro_id").val(item.FACT_QTY);

var a = document.getElementsByTagName("div");
var dom;
for(var k = 0,kk=a.length;k<kk;k++){
if(a[k].getAttribute("data-np-id") == pro_id){
dom = a[k];
break;
}
}
dom.getElementsByTagName("input")[0].value=item.FACT_QTY;
})
}
});

})

</script>

 

 

 

//php

<?
include_once ("inc/auth.inc.php");
$id = isset($_POST[‘app_id‘]) ? $_POST[‘app_id‘] : ‘0‘;
$query = "SELECT * FROM office_transhistory WHERE CYCLE_NO=".$id;

$cursor = exequery ( TD::conn (), $query );
$data="[";
while ( $ROW = mysql_fetch_array ( $cursor ) )
{
$PRO_ID = $ROW[‘PRO_ID‘];
$FACT_QTY = $ROW[‘FACT_QTY‘];
$data.="{\"PRO_ID\":\"".$PRO_ID."\",\"FACT_QTY\":\"".$FACT_QTY."\"},";
//$data.="{\"".$PRO_ID."\":\"".$FACT_QTY."\"},";

};
$data=substr($data,0,-1);
$data.="]";
file_put_contents("D:/txt.txt",$data);
echo $data;

php json dom解析

标签:

原文地址:http://www.cnblogs.com/xuhaohao/p/4779096.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!