Save a Javascript file as .php
<p>I have done this before to get data which needed to be looped into the javascript but this time it won't work. It all works fine when it is internal on the <code>index.php</code> file but doesn't work when it's an external file.</p>

<p>This is the code that is breaking it</p>

<pre><code>$('#filter').append('Select Club: &lt;select name="users" id="users"
  onchange="showUser();"&gt;&lt;option value="0" selected&gt;All Clubs:&lt;/option&gt;
  &lt;?php $query = "SELECT * FROM clubs"; $clubs = mysql_query($query);
  while($row = mysql_fetch_array($clubs)){ ?&gt;
  &lt;option value="&lt;?php echo $row['name']; ?&gt;"&gt;&lt;?php echo $row['name']; ?&gt;
  &lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; ');
</code></pre>
