1,105,384 Community Members

create an array in javascript using php mysql database

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
1
 

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
diafol
Where are my eyes?
12,949 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,846 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

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

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Question Answered as of 1 Year Ago by diafol
Member Avatar
diafol
Where are my eyes?
12,949 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,846 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

No prob - no harm done. ;)

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article