We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,348 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

create an array in javascript using php mysql database

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?

2
Contributors
4
Replies
5 Hours
Discussion Span
3 Months Ago
Last Updated
7
Views
Question
Answered
GraficRegret
Junior Poster
176 posts since Nov 2012
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 0

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

diafol
Keep Smiling
Moderator
10,668 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57

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.

GraficRegret
Junior Poster
176 posts since Nov 2012
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 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

GraficRegret
Junior Poster
176 posts since Nov 2012
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 0
Question Answered as of 3 Months Ago by diafol

No prob - no harm done. ;)

diafol
Keep Smiling
Moderator
10,668 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0721 seconds using 2.68MB