I would like to take the following php/mysql loop, and apply the results: $test,$test1,$test2 to the var Data object in the javascript code. This will make the var Data dynamic, pulling its data to construct the object form the database.
Tell me more
×
Stack Overflow is a question and answer site for
professional and enthusiast programmers. It's 100% free, no registration required.
closed as not a real question by Ryan, Andrew, Luksprog, cHao, Jason Sturges Sep 26 '12 at 17:55
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
Note that what I said about PDO/MySQLi still applies, this is just a minimal example to answer this specific question. (And in general, you should SELECT only those columns you will need, not |
|||
|
$res1
) into an array, and output it withvar treeData = <?php echo json_encode($rows); ?>;
. And please stop writing new code with the ancient mysql_* functions. They are no longer maintained and community has begun the deprecation process. Instead you should learn about prepared statements and use either PDO or MySQLi. If you care to learn, here is a quite good PDO-related tutorial. – DCoder Sep 21 '12 at 14:03