Jump to content

integrating JavaScriptwith PHP(having some issues)


Jago6060

Recommended Posts

I'm trying to pull images from a database and apply some JavaScript functions to them(mouseovers).  here is the code I have.

 

my functions...

 

<script language = "Javascript" type = "text/javascript">
function imgEnlarge(){
   document.getElementById('img').height += 100
   document.getElementById('img').width += 100
}
function imgShrink(){
   document.getElementById('img').height -= 100
   document.getElementById('img').width -= 100
}
</script>

 

and heres my php...

 

<?
include 'connect.php';
$tdcount = 0;

@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT * FROM images";
$result=mysql_query($sql);
$num=mysql_numrows($result);
mysql_close();

echo "<table border=0 align=center cellspacing=10 cellpadding=10><tr>";

$i=0;

while ($i < $num) {

$d1=mysql_result($result,$i,"id");
$d2=mysql_result($result,$i,"dir");

$img_dim = getimagesize($d2);
$num_img = array(1=>'128','176','320','352','550','640','704','720','768','800','1024');
$width = ($img_dim[0]);
$height = ($img_dim[1]);
$count = 0;

do {$count++;
   $width = ($img_dim[0]/$count);
   $height = ($img_dim[1]/$count);
}
while (($width > 75) && ($height > 75));


echo "<td><a href=$d2><img src=$d2 id=img border=0 width=$width height=$height onmouseover=imgEnlarge onmouseout=imgShrink></a></td>";
$tdcount++;
$i++;
if ($tdcount == 4){
echo "</tr>";
$tdcount = 0;
}
}
echo "</table>";
?>

oops, yeah sorry I forgot to list the issue.  When the images appear on the screen, the functions don't work.  but I have the exact same functions on my local computer that work.  I think it's how I have the PHP image echo line setup but I'm not sure.  I guess I kind of need a second set of eyes to see whats wrong.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.