JavaScript has no idea what PHP does... it doesn't even know PHP exists.
So your PHP script has to output your JavaScript in its entirety.
You need to have a line that not only defines message as an array, but
populates it. I would put a for loop after your reset($messages) line
that echo's each element into a JavaScript Array Statement
Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com
----- Original Message -----
From: "AJDIN BRANDIC" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 14, 2001 10:07 AM
Subject: [PHP] php java script
> Hi
>
> I am doing a scroll bar with javascript and info pulled from MySQL.
> So I execute query and create an array with php called messages. Then
> when my page is loaded I guess this array should be available to
> JavaScript under the same name except the $. Am I right here or not?
>
> The java script error is : messages not defined
>
> the code is:
> <html>
> <body>
> <table>
> <tr><td>Scroll Text</td></tr>
> <tr><td>
> <script language='JavaScript1.2'>
> <?php
> include("mydbconnection.php3");
> if(gettype($messages) != "array")
> { $messages = array(); }
>
> $query="select * from text";
> $results=mysql_query($query);
> while($result = mysql_fetch_array($results)) {
> $texttitle=$result['title'];
> $body=$result['body'];
> $mytext=$texttitle;
> $mytext=$body;
> array_push($messages, $mytext);
> }
> reset($messages);
> ?>
> if(messages.length>1) {
> id=1
> }
> ...........................
> </script>
> </td></tr></table>
> </body>
> </html>
>
>
> Regards
>
> Ajdin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]