I have generated a php array from oracle db (index.php)
while ($row = oci_fetch_array ($stid, OCI_ASSOC + OCI_RETURN_NULLS)){
$result[]=$row;
}
Now i have to pass this array to another php file for other processing.
<script language="javascript" type="text/javascript">
function sortme()
{
var d=document.getElementById("div");
var obj = <?php echo json_encode($result); ?>;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
d.innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getsorted.php?q=obj",true);
xmlhttp.send();
}
Then in the php file get sorted.php i need this double dimension array "result" back and sort it. So I use this, (getsorted.php)
<?php
$q=$_GET["q"];
$ans=json_decode(str_replace('\"','"',$q),true);
var_dump($q);
var_dump($ans);
?>
But i am not able to figure out anything.I am not able to retrieve the array back. If this is the wrong approach please suggest a correct approach.
Please do post the code.
Thanks a lot.
IS there a better way to do it???