Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.