liamallan
08-17-2010, 09:44 AM
hey guys, i am wondering if it is possible to implement the 'DD sticky tooltip' script into a map on my site?
atm, when u hover over the citys on the map, the tooltip appears, but all the citys have the same info(within the tooltip)
here is a link to the page (http://shiftysplayground.co.cc/map.php)
and here is my code:
<!--grid table-->
<table width="100%" height="100%" cellspacing="0" cellpadding="2" border="0" bgcolor="#009900">
<?php
//these 2 for loops represent the y and x axis
//using the data collected above the loops will properly display the grid
for ($Ty = $start_y; $Ty <= $end_y; $Ty++) {
//start new row
echo '<tr>';
for ($Tx = $start_x; $Tx <= $end_x; $Tx++) {
//show grid
DisplayGrid($Tx,$Ty);
}
echo '</tr>';
}
?>
<?php
function DisplayGrid($gridx,$gridy) {
global $x, $y;
//process.php
$host="localhost";
$username="username";
$password="password";
$db_name="database";
$tbl_name="table";
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select db");
$query = mysql_query("SELECT * FROM `mapdata`") or die(mysql_error());
while($rows=mysql_fetch_array($query)){
$id = $rows['id'];
$status = $rows['status'];
if ($gridx == $rows['x'] && $gridy == $rows['y']) {
if($status == 'FRIENDLY'){
echo "<td style=\"border: 1px;\" width=7 bgcolor=\"#00FFFF\" align=center valign=center data-tooltip=\"sticky1\"><font size='1'></font></td>";
?>
<div id="mystickytooltip" class="stickytooltip">
<div style="padding:5px">
<div id="sticky1" class="atip" style="width:200px">
<? echo $rows['x']; ?>, <? echo $rows['y']; ?><br />
<img src="../friendly.jpg" alt=""/><br />
<b>Lord Name:</b> <? echo $rows['lordname']; ?><br />
<b>Alliance:</b> <? echo $rows['alliance']; ?>
</div>
</div>
<div class="stickystatus"></div>
</div>
<?
}
if($status == 'HOSTILE'){
echo "<td style=\"border: 1px;\" width=7 bgcolor=\"#FF0000\" align=center valign=center data-tooltip=\"sticky2\"><font size='1'></font></td>";
?>
<div id="mystickytooltip" class="stickytooltip">
<div style="padding:5px">
<div id="sticky2" class="atip" style="width:200px">
<? echo $rows['x']; ?>, <? echo $rows['y']; ?><br />
<img src="../hostile.JPG" alt=""/><br />
<b>Lord Name:</b> <? echo $rows['lordname']; ?><br />
<b>Alliance:</b> <? echo $rows['alliance']; ?>
</div>
</div>
<div class="stickystatus"></div>
</div>
<?
}
}
}
echo "<td width=7 align=center valign=center><a href=\"index.php?xcord=$gridx&ycord=$gridy\"></a><font size=1></font></td>";
}
?>
</table>
this is the only thing that really needs fixing on the map so ur help will be appreciated
thanx :)
atm, when u hover over the citys on the map, the tooltip appears, but all the citys have the same info(within the tooltip)
here is a link to the page (http://shiftysplayground.co.cc/map.php)
and here is my code:
<!--grid table-->
<table width="100%" height="100%" cellspacing="0" cellpadding="2" border="0" bgcolor="#009900">
<?php
//these 2 for loops represent the y and x axis
//using the data collected above the loops will properly display the grid
for ($Ty = $start_y; $Ty <= $end_y; $Ty++) {
//start new row
echo '<tr>';
for ($Tx = $start_x; $Tx <= $end_x; $Tx++) {
//show grid
DisplayGrid($Tx,$Ty);
}
echo '</tr>';
}
?>
<?php
function DisplayGrid($gridx,$gridy) {
global $x, $y;
//process.php
$host="localhost";
$username="username";
$password="password";
$db_name="database";
$tbl_name="table";
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select db");
$query = mysql_query("SELECT * FROM `mapdata`") or die(mysql_error());
while($rows=mysql_fetch_array($query)){
$id = $rows['id'];
$status = $rows['status'];
if ($gridx == $rows['x'] && $gridy == $rows['y']) {
if($status == 'FRIENDLY'){
echo "<td style=\"border: 1px;\" width=7 bgcolor=\"#00FFFF\" align=center valign=center data-tooltip=\"sticky1\"><font size='1'></font></td>";
?>
<div id="mystickytooltip" class="stickytooltip">
<div style="padding:5px">
<div id="sticky1" class="atip" style="width:200px">
<? echo $rows['x']; ?>, <? echo $rows['y']; ?><br />
<img src="../friendly.jpg" alt=""/><br />
<b>Lord Name:</b> <? echo $rows['lordname']; ?><br />
<b>Alliance:</b> <? echo $rows['alliance']; ?>
</div>
</div>
<div class="stickystatus"></div>
</div>
<?
}
if($status == 'HOSTILE'){
echo "<td style=\"border: 1px;\" width=7 bgcolor=\"#FF0000\" align=center valign=center data-tooltip=\"sticky2\"><font size='1'></font></td>";
?>
<div id="mystickytooltip" class="stickytooltip">
<div style="padding:5px">
<div id="sticky2" class="atip" style="width:200px">
<? echo $rows['x']; ?>, <? echo $rows['y']; ?><br />
<img src="../hostile.JPG" alt=""/><br />
<b>Lord Name:</b> <? echo $rows['lordname']; ?><br />
<b>Alliance:</b> <? echo $rows['alliance']; ?>
</div>
</div>
<div class="stickystatus"></div>
</div>
<?
}
}
}
echo "<td width=7 align=center valign=center><a href=\"index.php?xcord=$gridx&ycord=$gridy\"></a><font size=1></font></td>";
}
?>
</table>
this is the only thing that really needs fixing on the map so ur help will be appreciated
thanx :)