Larger view of the issue is here: http://i1268.photobucket.com/albums/jj572/LinuxOwner/question.png


Question: Getting information from database and giving it to javascript
Answer: You should never need to build javascript with PHP, there's just no need (especially in Drupal, which already has a mechanism).

What you should do instead is put your JS in an external file, then use Drupal's JS settings to pass the data. So the JS file might look like:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {
      var locations = Drupal.settings.myModule.locations;
      // Do something with the locations var.
    }
  }
)(jQuery);


And in your page callback or whatever:

$settings['myModule']['location'] = db_query('SELECT * FROM {locations}')-&gt;fetchAll();
drupal_add_js($settings, 'setting');