Quote:
Originally Posted by Cyberpops
trying to pass several sql query array to further work in JS:
[PHP]
So the problem, as u can see is that it adds those [object, Object] values to my array.
|
you are adding those in in php.
i don't think you need the 3 while statements.
you should be able to do something like :
Code:
echo json_encode(mysqli_fetch_all(MYSQLI_NUM));
and just dump the whole result set at once. if you want the columns renamed, do it in sql using "dbName AS myName" in the SELECT.
without going into the reasons why document.write() is bad, you can view your data by using JSON.stringify() instead of coercing the objects to a string.
this is the same as php's differences between echoing a var_dump($x) -vs- just echo $x.
try something like this to get a peek:
Code:
myData= [price , min , max ]
document.write(
'<pre>' +
JSON.stringiyfy(myData, null, "\t" )
)
or use firebug to inspect the variables in real-time without "printing" the data by replacing document.write() with console.log() or console.dir().
there are also several template libs out there than make it trivial to turn json into html using nice clean syntax. those can make debugging easier by offering advices in their error-handling routines.
cheers