Hello everyone
I want to seperate JSON arry, the version 1.1 I can use
p[ind][name], p[ind][kkid]
but new version can not realize by this methods and bellow method can not be
success. Who can tell me how can I realize it? thank in advance.
Wang Suya
My mootools program is bellow:
.........
var pnode1 = tree.insert({text:'プロジェクト文書', id:'1'});
var snode1 = tree.insert({text:'社外文書',id:'2'});
var index1 = [];
var b = new String;
b = '';
b = "d0"+"="+1
var myajax = new
Request.JSON({url:"get_kokyaku.php",method:'post',onComplete:func
tion(mystring){
alert(mystring.p0);
var cnt = mystring.p0;
(cnt).times(function(ind){
var st = new String;
var sid = new String;
st = mystring.p+ind+.name;
sid = mystring.p+ind+.kkid;
alert(st);
alert(sid);
index1[ind] = pnode1.insert({text:st,id:sid});
})
}});
myajax.send(b);
my php program is bellow:
<?php
require_once('HTML/AJAX.php');
require_once('HTML/AJAX/JSON.php');
require_once('process.conf');
require_once('sql.inc');
require_once('tools.inc');
session_start();
$k = sprintf("d%d",0);
if(isset($_POST[$k])) $i =$_POST[$k];
$j = 1;
$r = sql_exec("select kkid,name from kokyaku where bunnsyo_bunnrui = '$i'");
while($ar = sql_fetch_array($r)){
$l = sprintf("p%d",$j);
$j++;
$a[$l]['kkid'] = $ar[0];
$a[$l]['name'] = $ar[1];
}
$a[p0] = $j;
$json = new HTML_AJAX_JSON();
$js = $json->encode($a);
print"$js";
?>
wang suya