is it posible to pass information held inside a MySQL database into a javascript array using PHP code? something like:

$sql = mysql_query("SELECT * FROM uploads WHERE ref_id = '$refID'");

//javascript below
var array = new Array()

while(<?php echo $row = mysql_fetch_array($sql)?>)
    array.push(<?php echo $row['name']; ?>)

or am I missing something here? of cource this is assuming that I have already defined the $refID and everything else is working propperly, should this build the array I am trying to create?

Votes + Comments
Like that of Facebook.com Right?
4 Years
Discussion Span
Last Post by diafol

Actually I asked if I could put a variable into a function in the other thread, the reason I asked this question is that I tried this code and it seemed not to work so I was asking if I was missing something in the code. I try my best to keep my thoughts and questions organised however adding a database item to a javascript array I believe is very different then adding a database item to a simple variable. I really am not trying to waste anyones time here D.


my appologies D i did not realise that the other thread stayed open I thought I had closed it so I opened this one right after that

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.