javasript in another file with php in it
<p>i want to tidy up my index.php.
i have some scripts which i want to move to another files.</p>

<p>atm i come to this, i hava javascript which has php in it to echo values from database.
i came to solution, copy that to another php file, like script.php, and just include it with php.</p>

<pre><code>&lt;!-- AUTO complete --&gt;
&lt;script src="/pages/JQuery/js/jquery-1.8.3.js"&gt;&lt;/script&gt;
&lt;script src="/pages/JQuery/js/jquery-ui-1.9.2.custom.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="/pages/JQuery/css/no-theme/jquery-ui-1.10.3.custom.css" /&gt;
&lt;?php include './pages/skripti/autocomplete.php'; //pats skripts ?&gt; 
</code></pre>

<p>and</p>

<pre><code>&lt;script&gt;
    jQuery(function($) {
        var availableTags = [
        &lt;?php 
            $names = $db-&gt;query("SELECT * FROM names");
            while ($name = $names-&gt;fetch_object()) {
                echo '"' . $name-&gt;rs_name . '",';
            }
        ?&gt;
        ];

        $( "#autocomplete" ).autocomplete({
            source: availableTags
        });
    });
&lt;/script&gt;
</code></pre>

<p>The question is: How good solution it is?</p>
