/    Sign up×
Community /Pin to ProfileBookmark

Location incorrect PHP/Javascript issue

Hi! I have what I hope is a simple problem.

I would like to incorporate the code found on this page:

[url]http://www.dynamicdrive.com/dynamicindex5/popinfo2.htm[/url]

onto my page. Notice how the text boxes pop up and move around with the mouse?

Well, when I code this the text box is popping up before any other item. Now, the trick is this. I want the value of the box to be dynamically filled in with a mysql request. So I am using PHP. Here is what I have so far:

[url]http://www.photomosaicproject.com/test.php[/url]

Notice how the names are appearing at the top of the page? Does anyone know why that is happening? I copied the code directly from that first page!

Thanks so much for any help!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@marcusamiMay 07.2008 — im not sure what the problem is,

but its on doing it in firefox for me

in IE its working

maybe look at

Xoffset=-60; // modify these values to ...

Yoffset= 20; // change the popup position.
[/QUOTE]



regardds

Marcus
Copy linkTweet thisAlerts:
@trevzillaauthorMay 08.2008 — Yeah I realized shortly after I posted this that the issue only exists in firefox. I'll post my code here for some people to pick through if they want. If you do, I thank you ever so much! And really quickly, another thing I have figured out is if the javascript is just after my first <body> tag, the text box appears very first thing on the screen, and doesn't move. If I paste the javascript at the end of the <body> the text box appears at the bottom of the page. Here is my code:

[code=php]<?php ob_start();
//header('Content-type: application/javascript');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Photomosaic.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Million Picture Photomosaic</title>
<style type="text/css">
<!--
#dek {position:absolute;visibility:hidden;z-index:200;}
//-->
</style>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body,td,th {
color: #FCFFF5;
}
body {
background-color: #193441;
background-image: url();
background-repeat: no-repeat;
}
a:link {
color: #91AA9D;
text-decoration: none;
}
a:visited {
color: #91AA9D;
text-decoration: none;
}
a:hover {
color: #D1DBBD;
text-decoration: none;
}
a:active {
color: #91AA9D;
text-decoration: none;
}
-->
</style>
<link href="photomosaic.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: small}
-->
</style>

</head>

<body>
<!-- InstanceBeginEditable name="PHP Inserts" -->
<?php

echo <<<JAVA
<div id="dek"></div>
<script type="text/javascript">
<!--

//Pop up information box II (Mike McGrath ([email protected], http://website.lineone.net/~mike_mcgrath))
//Permission granted to Dynamicdrive.com to include script in archive
//For this and 100's more DHTML scripts, visit http://dynamicdrive.com

Xoffset=-60; // modify these values to ...
Yoffset= 20; // change the popup position.

var old,skn,iex=(document.all),yyy=-1000;

var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all

if (ns4)
skn=document.dek
else if (ns6)
skn=document.getElementById("dek").style
else if (ie4)
skn=document.all.dek.style
if(ns4)document.captureEvents(Event.MOUSEMOVE);
else{
skn.visibility="visible"
skn.display="none"
}
document.onmousemove=get_mouse;

function popup(msg,bak){
var content="<table width=175 border=1 bordercolor=black cellpadding=2 cellspacing=0 "+
"bgcolor="+bak+"><td align=center><font color=black size=2>"+msg+"</font></td></table>";
yyy=Yoffset;
if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
if(ie4){document.all("dek").innerHTML=content;skn.display=''}
}

function get_mouse(e){
var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
skn.left=x+Xoffset;
var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
skn.top=y+yyy;
}

function kill(){
yyy=-1000;
if(ns4){skn.visibility="hidden";}
else if (ns6||ie4)
skn.display="none"
}

//-->
</script>
JAVA;
?>
<!-- InstanceEndEditable -->
<center>
<p class="webTitle">&nbsp;</p>
</center>

<table width="640" border="4" align="center" cellpadding="2" cellspacing="2" bordercolor="#999999">
<tr>
<td width="39"><div align="center"><a href="index.php">Home</a></div></td>
<td width="119"><div align="center"><a href="photographs.php">The Photographs</a></div></td>
<td width="83"><div align="center"><a href="buyspace.html">Buy Space</a></div></td>
<td width="160"><div align="center"><a href="whatare.html">What Photomosaics Are</a></div></td>
<td width="127" align="center"><div align="center"><a href="mail.php">Tell Your Friends</a></div></td>
<td width="54" align="center"><div align="center"><a href="FAQ.html">FAQ</a></div></td>
</tr>
</table>
<p class="links">&nbsp;</p>
<table width="95%" height="507" border="0" align="center">
<tr>
<td valign="top"><!-- InstanceBeginEditable name="MainText" -->
<?php
$dir = "/home/content/t/r/e/trevzilla/html/uploads/";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$images[] = $filename;
}
sort($images);
$count=count($images);
if ($count==2){
echo '<div align="center"><strong>This Website was posted on April 08, 2008 and as of yet, no pictures have been purchased. Be the first by clicking <a href="buyspace.html">here</a>!</strong></div>';
}
else{
$con = mysql_connect("server","user","password");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("trevzilla", $con);


//Display Images on page and link them to users website
for($i=$count-2; $i>0; $i--) {
$result = mysql_query("SELECT url FROM users WHERE picturenumber='" .$images[$i+1]. "'") or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_NUM);
$nameresult = mysql_query("SELECT firstname, lastname FROM users WHERE picturenumber='" .$images[$i+1]. "'") or die(mysql_error());
$name = mysql_fetch_row($nameresult);

echo '<a href="'.$row[0].'" target="_blank" ONMOUSEOVER="popup('This picture was uploaded by: '.$name[0].' '.$name[1].'','lightyellow')"; ONMOUSEOUT="kill()"><img src="/uploads/'.$images[$i+1] .'" border=0 width=200 height=200></a>';
}
mysql_free_result($result);

mysql_close($con);
}
?>



<!-- InstanceEndEditable -->
<p align="justify">&nbsp;</p></td>
</tr>
</table>
<p align="center">Questions? <a href="contact.html">Contact</a> me.</p>
<p align="center" class="style1">&copy; 2008 by Trevor Olson</p>
</body>
<!-- InstanceEnd --></html>
<?php ob_flush(); ?>[/code]
×

Success!

Help @trevzilla spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.30,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...