i want to tidy up my index.php. i have some scripts which i want to move to another files.
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.
<!-- AUTO complete -->
<script src="/pages/JQuery/js/jquery-1.8.3.js"></script>
<script src="/pages/JQuery/js/jquery-ui-1.9.2.custom.js"></script>
<link rel="stylesheet" type="text/css" href="/pages/JQuery/css/no-theme/jquery-ui-1.10.3.custom.css" />
<?php include './pages/skripti/autocomplete.php'; //pats skripts ?>
and
<script>
jQuery(function($) {
var availableTags = [
<?php
$names = $db->query("SELECT * FROM names");
while ($name = $names->fetch_object()) {
echo '"' . $name->rs_name . '",';
}
?>
];
$( "#autocomplete" ).autocomplete({
source: availableTags
});
});
</script>
The question is: How good solution it is?