title: Passing Results from SQL to Google Maps API in CodeIgniter
body: <p>I'm hoping to use Google Maps on my site.</p>
  
  <p>My addresses are stored in a DB. I’m pulling up a page where the information is all dynamic. For example: mysite.com/site/business/5 (where 5 is the id of the business).</p>
  
  <p>Let’s say I do a query like this:</p>
  
  <pre><code>function addressForMap($id) {
  $this-&gt;db-&gt;select('b.id, b.busaddress, b.buscity, b.buszip');
  $this-&gt;db-&gt;from('business as b');
  $this-&gt;db-&gt;where('b.id', $id);
  $this-&gt;db-&gt;limit(1);
  </code></pre>
  
  <p>// add a limit
      $this->db->limit(1);</p>
  
  <pre><code>// get the results.. cha-ching
  $q = $this-&gt;db-&gt;get();
  
  // any results?
  if($q-&gt;num_rows() !== 1)
  {
      return FALSE;
  }
  
  return $q-&gt;row();
  </code></pre>
  
  <p>}</p>
  
  <p>How can I output the info to the Google Maps API correctly so that it displays the map appropriately?</p>
  
  <p>The API interface takes the results like this: <code>$marker['address'] = 'Crescent Park, Palo Alto';</code>.</p>
  
  <p>Here's what I have in the controller:</p>
  
  <pre><code>$marker = array();
      $address = $this-&gt;Business_model-&gt;addressForMap($id); //Get result row
      $marker['address'] = $address-&gt;busaddress .' '.$address-&gt;buscity .', '. $address-&gt;buszip;
  </code></pre>