You can't "combine" javascript and PHP -- not in the way that you're suggesting. PHP and javascript are two different languages, so you can't just include javascript from within PHP and expect it to work.
Beyond that, there's something extremely important that you need to understand -- Javascript is a CLIENT SIDE language (executed on the user's machine in the web browser) and PHP is a SERVER SIDE language (executed on the webserver machine).
PHP is used to generate output. 99% of the time, that output is HTML and/or Javascript. As such, PHP is done executing before a single line of javascript starts executing.
Code:
+--------+ Client sends an HTTP Request +--------+
| client | -----> for index.php ---> | server |
+--------+ +--------+
|
PHP interpreter
runs index.php
script, which
outputs HTML and
javascript.
|
V
+--------+ HTML and Javascript text +--------+
| client | <---- output created by index.php ---- | server |
+--------+ +--------+
|
|
Client web browser
executes javascript
code and renders
the page.
|
V
+--------+ +--------+
| client | | server |
+--------+ +--------+
Notice that when PHP is executing, the client side is just waiting for a response. Also note that when the client is executing the javascript, there is NO connection between the web server and the client -- the server is completely unaware of the client's presence after the output of PHP is sent.
Take care,
Nik
http://www.bigaction.org/