So I want to call my database with php and write the values to an array. Then I want to loop through the array in php and write all variables to javascript variables. I could then use the variables later in the <script> section.
Here's an (incorrect) example of what I think should work. Use it as a jumping off point if you like...
Code: Select all
<?php
//----assume I already pulled all the array values out and stored them in array called $theArray
$i=1;
foreach($theArray as $value){
echo '<script> var theVar'.$i.' = "'.= $fred2 .'"; </script>';
$i++;
}
//----now test that at least the first js var was written...
?>
<script>
document.write(theVar1)
</script>