yollow 0 Newbie Poster

Hi all,

I have a code that will fetch out the data from database OnMouseOver. But it is working fine if don't add table on the div which will come OnMouseOver. If i try to show the fetched data in table then the code doesn't work. Please someone help me with this.

Here is my code:

<script type="text/javascript" language="JavaScript">

var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {

rX = self.pageXOffset;
rY = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop) {

rX = document.documentElement.scrollLeft;
rY = document.documentElement.scrollTop;
} else if (document.body) {

rX = document.body.scrollLeft;
rY = document.body.scrollTop;
}
if(document.all) {
cX += rX;
cY += rY;
}

d.style.left = (cX+10) + "px";
d.style.top = (cY+10) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}

</script>

</head>

<body>
<table width="300">
  <tr id="Ar tui?">
    <td>MakeID</td>
    <td>Make</td>
    <td>Veh Type</td>
  </tr>
<?php
$conn = mysql_connect ('localhost', 'root', '');
mysql_select_db ('php_class', $conn);

function create_div($width, $height, $fields, $table, $w_field, $w_value, $unique){
$f = implode("`, `", $fields);
$sql = "SELECT `$f` FROM `$table` WHERE `$w_field` = '$w_value'";
$res = mysql_query($sql) or die(mysql_error());
$div = '<div';
$div .= "<div align=center id=\"data".$unique."\" style=\"margin:10px 10px 10px 10px; overflow:hidden; display:none; position:absolute; border-style:solid; background-color:white; padding: 10px; width:".$width."px; height:".$height."px\" />\n";

$div .= '<table width="100%" cellpadding="4" cellspacing="2">';
$div .= '<tr><th>Serial</th><th>First Name</th><th>Email</th></tr>';

 while($r = mysql_fetch_assoc($res)){
    $div .= '<tr id="tui">';
	$div .= '<td>'.$r['id'].'</td>';
	$div .= '<td>'.$r['firstname'].'</td>';
	$div .= '<td>'.$r['email'].'</td>';
	
  $div .= "</tr>";
  }
$div .= "</table>";
$div .= "</div>\n";
return $div;
}

$sql = "SELECT * FROM name";
$res = mysql_query($sql) or die(mysql_error());
$i=0;
$fields = array("id", "firstname", "email");
while($r = mysql_fetch_assoc($res)){
  echo create_div("600", "200", $fields, "admin", "id", $r['id'], $i);
?>

  <tr id="tui na">
    <td><?php echo $r['id']; ?></td>
    <td><a onmouseover="ShowContent('data<?php echo $i; ?>'); return true;" onmouseout="HideContent('data<?php echo $i; ?>'); return true;" href="#"><?php echo $r['name'];?></a>
    </td>
    <td><?php echo $r['desc']; ?></td>
  </tr>
<?php
$i++;
}
?>
</table>
</body>
</html>

Thanks in Advance.