title: PHP get some data from database then echo it out into a JS file
body: <p><strong>MYSQL table structure:</strong>
  id , name , status , color</p>
  
  <p>how can i use PHP to get some data from my database(mysql) ,the php script will look for table rows that have <strong>"good"</strong> in the <strong>"status"</strong> column. Then echo those rows which have good in status(P/S  out into  a JS file. It also get the color from each row (with status=good) and ptu it into javascript(jQUery)</p>
  
  <p>I did a little research on how to use php to generate javascript.</p>
  
  <p>Here's a php script, it's not working btw:</p>
  
  <pre><code>&lt;?php
  header("content-type: application/x-javascript");
  
    include 'connect.php';
    $sql = "SELECT * FROM users WHERE status ='good'"; 
    $query = mysql_query($sql)or die(mysql_error());
  
    $rows = array();
  while($row = mysql_fetch_array( $query )){
    $rows[] = $row;
    echo "$('a[href*=\"row[username]\"]').css('color', 'row[color]');\n";
  }
  
  ?&gt;
  </code></pre>
  
  <p>The out put is (which wont work):</p>
  
  <pre><code>$('a[href*="row[username]"]').css('color', 'row[color]');
  </code></pre>
  
  <p>The connect.php is working(connects to database) , just the script is not working.</p>
  
  <p>(BTW: The file name of this is <strong>usercolor.js.php</strong> , is it correct?)
  I hope someone could guide me.</p>
  
  <p>Thanks and have a wonderful day.</p>