PHP array to javascript

Hi!
I want use this array:

[php]<?php
$sql = db_query(get_specified_items($item, $classcode, $plancode, $type, $desc, $area, $type));
for ($i=0;$i<db_num_rows($sql);$i++)
{ $row = db_fetch($sql); $myarray[$i]=$row[0]; }
?>[/php]

in this javascript code:

[code]

[/code]

How can I do it? I tried find help with google, but it didnt work :frowning: Thank youuuu

Hi there,

I think your concern is how do you obtain values from the database and assign it to your javascript object like availableTags . You can do something like this:

[php] var availableTags = [<?php myData();?>];[/php]

myData() should return a comma-separated values. Play around with implode() and explore().

Sponsor our Newsletter | Privacy Policy | Terms of Service