title: Generate Javascript Array from Mysql select
body: <p>I wonder if anyone can help - I want to select a table and create Javascript a array with the return values. Here's what I have so far:</p>
  
  <pre><code>con = mysql_connect("localhost","usrname","password");
  
  if (!$con) {
      die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db("my_db", $con);
  $ql = "SELECT theMessage FROM email_message";
  $result = mysql_query($ql) or die(mysql_error());
  
  while ($row = mysql_fetch_array($result)) {
      $allMessage = $row['theMessage'] . " ";
  }
  
  $arr = array($allMessages);
  $script = '&lt;script&gt;var newArr = new Array(' . implode(' ', $arr) . ');&lt;/script&gt;';
  echo $script;
  </code></pre>
  
  <p>But instead, it just shows me empty array like this: var newArr = new Array(); </p>