Re: php java script

From: Date: Fri, 14 Sep 2001 15:28:37 +0000
Subject: Re: php java script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67381@lists.php.net to get a copy of this message
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" <abrandic@coventry.ac.uk> To: <php-general@lists.php.net> 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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#67381) next »