Jump to content

Ie error images


Xagrik

Recommended Posts

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
}

 

??

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.