I have to create a javascript array whose elements are fetched by php from a database. Is it possible? If so, how?
(I dont want to use ajax to do that)
Collect the values in an array and convert it to JSON with json_encode:
$array = array(); while ($row = mysql_fetch_assoc($result)) { $array[] = $row['key']; } echo 'var array = '.json_encode($array).';';