Jump to content

javascript in php code


leon

Recommended Posts

Hello, I was trying to insert rollover image script to php. But I dont think it will be easy. can you check this code please? How can it be adjusted?


[code]
<?php echo "<a href=\"$PHP_SELF?page=$pageNum&product_id={$data['id']}\" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image71','','{data['image_roll']}',1)">"; ?>
[/code]

Image_roll is the field from the database.
Link to comment
https://forums.phpfreaks.com/topic/7345-javascript-in-php-code/
Share on other sites

you might be forgetting to escape your quotes. When using quotes within quotes, you need to put a backslash infront of the internal quote...

so, "\"" would equal "

I added backslashes to your code around the mouseover and mouseout -- should work fine now.


[code]
<?php echo "<a href=\"$PHP_SELF?page=$pageNum&product_id={$data['id']}\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image71','','{data['image_roll']}',1)\">"; ?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/7345-javascript-in-php-code/#findComment-26793
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.