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?

Member Avatar for diafol

You asked this in your other thread - which I answered. Please keep it organized.

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

Member Avatar for diafol

No prob - no harm done. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.