title: PHP MySQL JSON output
body: <p>I am trying take data from a MySQL table and create a JSON output in the below format.</p>
  
  <pre><code>{
      markers: [
      {
         latitude: 57.7973333,
         longitude: 12.0502107,
         title: "Angered",
         content: "Representing :)"
      },
      {
         latitude: 57.6969943,
         longitude: 11.9865,
         title: "Gothenburg",
         content: "Swedens second largest city"
      }
    ]
  }
  </code></pre>
  
  <p>Here is the PHP I am using to generate the JSON</p>
  
  <pre><code>$model  = array();
  
      $query = "SELECT title, content, lat, lng FROM locations_tbl";
  
      //Get records from database
      $result = mysql_query($query, $con);
  
      if(mysql_num_rows($result)) {
          while($e = mysql_fetch_assoc($result)) {
              $model['title'][]       = $e['title'];
              $model['content'][] = $e['content'];
              $model['lat'][]     = $e['lat'];
              $model['lng'][]     = $e['lng'];
          }
      }
  
      header('Content-type: application/json');
      print json_encode(array('marker'=&gt;$model));
  </code></pre>
  
  <p>Below is the output that I get with the above code:</p>
  
  <pre><code>{
     marker: {
        title: [
            "Marker 1",
            "Marker 2",
            "Marker 3",
            "Marker 4",
            "Marker 5"
         ],
         content: [
            "Text 1",
            "Text 2",
            "Text 3",
            "Text 4",
            "Text 5"
         ],
         lat: [
            "46.99065400",
            "47.03520400",
            "47.20387700",
            "47.62574900",
            "47.43443400"
         ],
         lng: [
            "-122.92164800",
            "-122.81614600",
            "-122.24486400",
            "-122.14453800",
            "-122.46088200"
         ]
     }
  }
  </code></pre>
  
  <p>Any suggestions?</p>