<?php $query = "SELECT * FROM ... BY ..."; $result = mysql_query($query); while($row = mysql_fetch_row($result)){ $mass[] = $row;} $json = json_encode($mass, JSON_UNESCAPED_UNICODE); ?>
<script> var data = <?= $json ?>; </script>