I am selecting two image from database and want to show them onMOuseOver
and onMouseOut
.
Here is my code:
<img onmouseover="this.src=' .$him[0]. '" onmouseout="this.src='.$image_full[0].'" src="'.$image_full[0].'" />
I am selecting two image from database and want to show them onMOuseOver
and onMouseOut
.
Here is my code:
<img onmouseover="this.src=' .$him[0]. '" onmouseout="this.src='.$image_full[0].'" src="'.$image_full[0].'" />
I'm not sure if you like php print html code or html print php code, in both cases, be carefull with ' and ":
PHP print html code:
echo '<img onmouseover="this.src=\'' .$him[0]. '\'" onmouseout="this.src=\''.$image_full[0].'\'" src="'.$image_full[0].'" />';
HTML print PHP code:
<img onmouseover="this.src='<?php echo $him[0] ?>'" onmouseout="this.src='<?php echo $image_full[0] ?>'" src="'<?php echo $image_full[0] ?>'" />
If you try html print php code, you need to save your html code as php code
Could be the single quotatation marks in the 'src' property. Seems like they shouldn't be there, only for the javascript events because there's a string inside a string.
Without the extra single quotation marks it seems to work just fine for me.
Example:
<img
onmouseover="this.src='https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/AndalusQuran.JPG/94px-AndalusQuran.JPG'"
onmouseout="this.src='https://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Nacreous_clouds_Antarctica.jpg/110px-Nacreous_clouds_Antarctica.jpg'"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/140626_Tierser_Alpl_Rossz%C3%A4hne.jpg/245px-140626_Tierser_Alpl_Rossz%C3%A4hne.jpg"
/>