views:

170

answers:

1

HI Please help to fix this code , i use <a href="http://example.com/index.html" onMouseOver="doTooltip(event,'http://example.com/image_6.06.jpg','Image TITLE')" onMouseOut="hideTip()" title="in TITLE">TITLE</a>

in this code but its not work

    <? 
    $sql = "select * from wallpaper order by wallpaperid desc limit 20"; 
$result = mysql_query($sql, $db) or die(mysql_error()); 
if(mysql_num_rows($result)) { 
while($myrow = mysql_fetch_array($result)) { 
   $title = substr($myrow['title'] ,0,31);
   $wurl = ereg_replace(" ", "-", $myrow['title']);
   $html = '<dt><a href="%s-%s.html" onMouseOver="doTooltip(event,\'.$siteurl/wallpapers/thumbs/$wallpapername_$wallpaperid.jpg.\',"Image TITLE")" onMouseOut="hideTip()">%s..</a></dt>';
printf($html, $wurl, $myrow["wallpaperid"], $myrow["wallpapername"], $myrow["title"], $category);
} } 

?>

plsease someone help me to fix this Second code not work onmouseOver TIP

+1  A: 

First of all, this is purely a front-end (that is, Javascript/HTML) problem. It has nothing to do with PHP. You haven't actually provided enough information to help pinpoint the issue. It would be much more helpful to see your "doTooltip" and "hideTip" javascript functions.

That said, I notice that you're attempting to use variables $siteurl, $wallpapername, and $wallpaperid variables in your link string. You cannot use PHP variables in a string delimited with ' (single quotes).

Try this:

$html = '<dt><a href="%s-%s.html" onMouseOver="doTooltip(event,\''.$siteurl.'/wallpapers/thumbs/'.$wallpapername.'_'.$wallpaperid.'.jpg.\',"Image TITLE")" onMouseOut="hideTip()">%s..</a></dt>';

But I suspect that this isn't related to the problem you're actually trying to solve. I'd recommend that you revise your question. Leave out the PHP this time and only show the final output generated by your script. Good luck!

Brian Lacy
@Hassan: And note that `$siterl`, `$wallpapername` and `$wallpaperid` have to be defined first of course (which they are not in your code).
Felix Kling