![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
New Coder ![]() Join Date: Jan 2005
Posts: 62
Thanks: 1
Thanked 0 Times in 0 Posts
![]() |
mysql data into an array
Hi, I'm still quite new to php and mysql and thus have run into the following problem. I would like to read IDs from a database into an array and then pass that array to a javascript function. If I'm thinking correctly, this should be possible as php is server side and javascript client side. Anyways, I've got the following query:
mysql_query("SELECT id FROM hatchery WHERE parent='0' ORDER BY id") and want to pass the selected ids into an array to be used by a javascript function. Any help would be appreciated! Thanks |
|
|
|
|
|
PM User | #2 |
|
Master Coder ![]() ![]() Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
it's not a mysql issue. what server side language are you using? PHP?
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
|
|
|
PM User | #4 |
|
Master Coder ![]() ![]() Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
something like
PHP Code:
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
|
|
|
PM User | #5 |
|
New Coder ![]() Join Date: Jan 2005
Posts: 62
Thanks: 1
Thanked 0 Times in 0 Posts
![]() |
Thanks for the help!
Just one more question. Is is possible to then pass that array to a function as an argument? For example... while(list($id, $parent) = mysql_fetch_row($result)) { $str.=CreateItem($id, $parent, $arrItems1); } return($str); Function CreateItem($id, $parent, $arrItems1) { CODE } |
|
|
|
|
|
PM User | #6 |
|
Master Coder ![]() ![]() Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
No.
If you wanna use it as a javascript-array, then it is sent to the browser --> javascript = clientsided. So the PHP is just generating the html-code that you need for your clientside javascript. if you want to use it as a PHP array, then you need: PHP Code:
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|