Acmlm's Board - I2 Archive - Programming - PHP and Javascript
User | Post |
Tuvai
Posts: 191/211 |
You output Javascript the same way in PHP as you output HTML. |
Rydain
Posts: 111/738 |
Both languages have different purposes. JavaScript is a client-side language interpreted by the browser. PHP is a server-side language - a web server parses PHP files to create HTML, which it displays to the person viewing your site. JS is perfect for the mouseovers you described, but pulling data out of MySQL requires a server-side language like PHP (because the server can see the database, but - assuming proper security on your web server - a random person viewing the page can't). You can certainly use both at once - just have the PHP script that generates a page spit out the necessary JavaScript, or save the JavaScript to an external file and make sure that you link to it in the head of the generated page. |
Dragato
Posts: 20/25 |
Is it possible to use Javascript and PHP together, for the list of affiliates on my site I use javascript to show the sites 88x31 when you hover over the link.
But now that I've made an affiliate application feature which stores them all in the MySQL database I need it to list all of the affilates that have been acceted, obviously using PHP. So would it be possible to keep the javascript, or is there a PHP function which would do the trick?
Javascript by the way:
image0=new Image image1=new Image
image0.src=http://rpg-ascension.aerocore.net/images/8831b.gif image1.src=http://hg.aerocore.net/images/8831c.gif
a href=http://hg.aerocore.net onMouseOver=document.imagename02.src=image1.src onMouseOut=document.imagename02.src=image0.src target=_blank |
|