Xagrik Posted July 14, 2008 Share Posted July 14, 2008 Hi everyone!! I'm developing a website in php/mysql. The database have 4 image fields, but in some cases i just use 2 or 3, the other image fields are empty. The page where i show the rows os the database was developed with the 4 fields in it. In firefox everything is allright, but in IE the empty image fields are shown as the image below. Can anyone help me to solve this problem? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
trq Posted July 14, 2008 Share Posted July 14, 2008 We need to see the relevent code. That image indicates your browser cannot find the image. Quote Link to comment Share on other sites More sharing options...
Xagrik Posted July 14, 2008 Author Share Posted July 14, 2008 The code: <a href="<?php echo $row_motos['img1']; ?>" rel="lightbox"><img src="<?php echo $row_motos['img1']; ?>" width="250" height="187" border="0" /></a> <a href="<?php echo $row_motos['img2']; ?>" rel="lightbox"><img src="<?php echo $row_motos['img2']; ?>" width="250" height="187" border="0" /></a> The problem is when the img2 field is blank should not appear anything, in firefox works fine, but in IE shows that image :S Quote Link to comment Share on other sites More sharing options...
ChadNomad Posted July 14, 2008 Share Posted July 14, 2008 What does this output? print_r($row_motos); Quote Link to comment Share on other sites More sharing options...
Xagrik Posted July 14, 2008 Author Share Posted July 14, 2008 Nothing, it stays equal :s Quote Link to comment Share on other sites More sharing options...
ChadNomad Posted July 14, 2008 Share Posted July 14, 2008 The reason your getting the "X" image with Internet Explorer is because the image doesn't exist (or your linking to it wrong). That's just the way the browser behaves. Are you sure you aren't trying to display an image depending on whether it's set in your array? You could do something like: if (isset($row_motos['img1'])) { // print the HTML for img1 } else { // print the HTML for img2 } ?? Quote Link to comment Share on other sites More sharing options...
Xagrik Posted July 14, 2008 Author Share Posted July 14, 2008 I'm not sure, but i think that i could not use the code you gave me, because the structure of my code is already set to show all the image fields, and if i put a default image, it will link to a blank image (i'm using lightbox to enlarge the images). I just don't finde a way to hide that image if it doesn't exist in the database :s Quote Link to comment Share on other sites More sharing options...
ChadNomad Posted July 14, 2008 Share Posted July 14, 2008 You really do need to show more code... If you want to hide the image use CSS. For example: <img src="<?php echo $row_motos['img2']; ?>" width="250" height="187" border="0" style="visibility:hidden;" /> Quote Link to comment Share on other sites More sharing options...
wrathican Posted July 14, 2008 Share Posted July 14, 2008 if i were you i would use a while statement. <?php $query = ""; $result = mysql_query($query); while $row = mysql_fetch_array($result)) { //gets vars $image = $row['col']; //display images here like so ?> <img src="/images/<?php echo $image; ?>" alt="image" /> <?php } <? and please, if your going to make the site standards compliant DO NOT forget to add the alt="" tag. Quote Link to comment Share on other sites More sharing options...
Lamez Posted July 14, 2008 Share Posted July 14, 2008 view your source code, and see what image it is trying to show. Quote Link to comment 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.