Hi. I'm trying to get my hover-effect to work , but the php seems to destroy the hoverfunction. My javascript works fine if I remove all php-code. What have I done wrong?

 <?php
$host="*********"; // Host name 
$username="**********"; // Mysql username 
$password="geronimo"; // Mysql password 
$db_name="***********"; // Database name
$tbl_name="****"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY nummer";
$result=mysql_query($sql);
?>
<?php
while($rows=mysql_fetch_array($result)){
?>
<hr width="520" color="#FFF" size="1px" />
<table align="center" width="520" border="0" cellpadding="4" cellspacing="2" class="table2">
        <tr>
          <td width="60" height="80" align="left" class="bread"><? echo $rows['nummer']; ?></td>
          <td width="223" align="left" class="bread"><? echo $rows['titel']; ?></td>
          <td width="78" align="center" class="bread"><? echo $rows['pris']; ?></td>
          <td width="117" align="center" valign="middle">
          <a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image1','','../../images/uppdatera.png',1)"><img src="../../images/uppdatera2.png" name="Image1" width="120" height="27" border="0" id="Image2" /></a><br />
          <a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','../../images/tabort1.png',1)"><img src="../../images/tabort2.png" name="Image2" width="120" height="27" border="0" id="Image2" /></a><br />
          </td>
        </tr>
  </table> 
  <?php } ?>
  <?php mysql_close($con); ?>

make sure the javascript file is referenced by this page. Otherwise the MM_swapImgRestore and MM_swapImage functions will be undefined js functions. Make sure of that and please let us know.

I fixed it by doing it with DIV-tags instead..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.