title: Passing php array to javascript
body: <p>I have created a Google Map using JavaScript (v3 api). I have popped a couple of markers onto this, just to show it can be done. I have added some text to a text box specific to each marker, just to see if it can be done. Both marker and text box are ugly, but that's a problem for a different day. The map takes up around 75% of screen width and 100% screen height.
  I have a mySQL db of user posts. The data includes a post #id, a category, an ip address, a longitude value, a latitude value, a city, a user name, a heading and post content.
  I have 'floated' a table containing post category and heading up beside the map, using PHP to query the db, shoving the db rows into an array and using this as the source for the table. This takes up the remainder of the display width.</p>
  
  <p>Fine, so far.</p>
  
  <p>I want to add a marker for each post so that the marker is located at the longitude and latitude from which the post originated. I want to add content to a marker text box that is specific to that post (e.g. city, user name, post heading, post content).
  Further, I want to be able to link the posts in the displayed table to the map markers so that, for instance, a mouse-over event on a particular post in the table might cause the text box associated with that marker to become visible.</p>
  
  <p>But I cannot seem to find a way to pass the PHP array to the Google Map JavaScript so that I can use this to add the markers as required.
  Nor have I yet been able to find a way to associate a mouse over event on an object external to a Google map to a Google map marker.</p>
  
  <p>I have done extensive research and have found similar requests for the former - passing a PHP array to JavaScript. The suggested solution is usually to create a string from the PHP array with some sort of separator, e.g. a comma, and pass this to JavaScript where it is reformed into an array. I do not believe this would work in my case.</p>
  
  <p>My current code resides in a single file. The style stuff is located in a style section in the html head section and can be moved to a separate css file later. The Google map JavaScript are in script sections, again in the html head and can be moved to a separate js file. The body contains just a little html - divs for the map-canvas and the table with PHP
  to acquire the database rows in a single PHP array and to create the html for the table.</p>
  
  <p>I am aware that 'PHP is server side technology while JavaScript is client side' as has been indicated many times. 
  But surely there must be some way to pass an array of data obtained by PHP from a SQL db (not that the data origin is particularly relevant) to JavaScript code?</p>
  
  <p>I apologise for being so verbose, and if my questions have been answered somewhere I have missed, or misunderstood. Or if I am being particularly stupid.</p>
  
  <p>Take care.</p>
  
  <p>Mike</p>
  
  <p>Adding this by editing the original post.</p>
  
  <p>OK. I might have found an answer to my second question: how to create a link from an external element to a Google map marker. <a href="http://econym.org.uk/gmap/mouseover.htm" rel="nofollow">http://econym.org.uk/gmap/mouseover.htm</a> Always the way, after giving up looking for something that item is found.</p>
  
  <p>Mike</p>