<script type="text/javascript">
var category = new Array("category1", "category2");
</script>
My question is, I have this PHP query:
<?php $query = mysql_query("SELECT category FROM table ORDER BY category DESC") or die(mysql_error());
while($sql = mysql_fetch_assoc($query))
{
echo $sql['category'];
}
?>
How can I add $sql['category'] as the javascript "category"'s parameter?
mysql_xxx()
functions are deprecated and their use is discouraged. You should consider switching to a more modern API such as the PDO library.