Jump to content

[SOLVED] NEED HELP QUICKLY PROJECT DEADLINE IS TOMORROW!!!


Jago6060

Recommended Posts

I'm have my project setup to pull images from a database and display them on the screen with some basic JavaScript functions.  I get the images to come up but I can't get the javasccript functions to work on those images.

 

 

heres 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>

 

 

heres my PHP that displays the images...

 

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

@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT * FROM crc_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,"img_id");
$d2=mysql_result($result,$i,"img_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>";
?>

 

PLEASE HELP ASAP,  it would be greatly appreciated!!!

Might have to do with the fact that you are giving your images an id=img.  I don't think your javascript will target them if there is more than one image with the same id. Try giving each one an id equal to the primary key of the images table then passing that id to the javascript function.

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.