Jago6060 Posted June 10, 2007 Share Posted June 10, 2007 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/54926-solved-need-help-quickly-project-deadline-is-tomorrow/ Share on other sites More sharing options...
chigley Posted June 10, 2007 Share Posted June 10, 2007 echo "<td><a href=$d2><img src=$d2 id=\"img\" border=0 width=$width height=$height onmouseover=\"imgEnlarge()\" onmouseout=\"imgShrink()\"></a></td>"; Have you tested your Javascript functions? Quote Link to comment https://forums.phpfreaks.com/topic/54926-solved-need-help-quickly-project-deadline-is-tomorrow/#findComment-271700 Share on other sites More sharing options...
calabiyau Posted June 10, 2007 Share Posted June 10, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/54926-solved-need-help-quickly-project-deadline-is-tomorrow/#findComment-271783 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.