not sure if this can actually be done – OK probably can be done but beyond me. I have a php recursive array function like this:
function recursive_array($results) {
global $DBH;
if(count($results)) {
echo $res->Fname;
foreach($results as $res) {
$STH = $DBH->query("SELECT FID,FParentID,Fname FROM list WHERE FParentID = " . $res->FID ."" );
$fquerycount = $STH->rowCount();
$STH->setFetchMode(PDO::FETCH_OBJ);
recursive_array($STH);
}}}
which starts on the page like this:
$FID = isset($_GET['FID']) ? $_GET[' FID'] : 0;
$STH = $DBH->query("SELECT FID,FParentID,Fname FROM list WHERE FParentID ='0' " );
$STH->setFetchMode(PDO::FETCH_OBJ);
recursive_array($STH);
This function works well for me. BUT it is “plain” php. what I would like to do is to create a json array rather than echo out the results. Then to parse the results through JQuery. My reason is I am using $.getJSON('etc...') for cross domain functionality with a “central” DB. OK I can use Iframes and just create “template” pages at the “central” domain, but I would prefer not to. (I just hate frames/Iframes)
Any suggestions / comments?
This is what I’ve done, actually in javascript: