Getting Database Values In Javascript Variable Dynamically
I researched this subject many times but I could not find the right answer to my question. Let me explain it. I'm creating an app with the Google Maps API where I want to have mul
Solution 1:
$post
is your iteration variable, so it only contains one element of the array at a time. If you want the entire array, assign that:
var bedrijven = <?php echo json_encode($query); ?>;
Solution 2:
The examples on http://us1.php.net/json_encode should be helpful. It looks like your $post should be an associative array:
$post[] = ("name"=>"test","lat"=>52.351753, "lon"=> 5.002035); ?>
var bedrijven = <?php echo json_encode($post); ?>;
outputs:
var bedrijven = [{"name":"test","lat":52.351753,"lon":5.002035}];
Post a Comment for "Getting Database Values In Javascript Variable Dynamically"