Problems embedding Javascript within PHP
-
Hi guys, I’ve installed the Exec-PHP and Inline Javascript plug-ins for a project I’m working on. Up to this point the PHP has been separate from the Javascript, but I need to populate a JS array from a MySQL query.
What I’d like to know is if it’s at all possible to embed Javascript within PHP (or vice versa) using these plug-ins. So far what I’ve tried hasn’t been working.
I found this site: http://codingforums.com/showthread.php?t=52060
But unfortunately I can’t seem to embed the two languages together. The following code appears to do nothing:
[inline] <script type="text/javascript"> <?php echo 'asdfsadfa';?> </script> [/inline]And this will throw a syntax error because of the [inline] tags:
<?php [inline] <script type="text/javascript"> document.write('Hello World!'); </script> [/inline] ?>Is there any way to accomplish what I’m doing? I don’t know Javascript too well. The array is supposed to collect latitude/longitude points so I can put them down as markers on a Google map.
The topic ‘Problems embedding Javascript within PHP’ is closed to new replies.