Jump to content

Images with NULL value in MySql


Recommended Posts

I’m making a page for a friend. He will add some text an upload some pictures to the page. All this is saved in MySql. He have the possibility to upload 5 pictures to each text. If he the only upload 2 pictures we will have some boxes with a red x.

 

Then I made this.

 

and I believe I have forgotten something.

 

 

 

 <?php if($row_Bilder['bilde1'] != "") { ?>    <div align="center"><a href="<?php echo $row_Bilder['bilde1']; ?>"><img src="<?php echo $row_Bilder['bilde1']; ?>" width="80" height="80" border="0"></a></div>  <?php } ?></td><td width="103">  <?php if($row_Bilder['bilde2'] != "") { ?>    <div align="center"><a href="<?php echo $row_Bilder['bilde2']; ?>"><img src="<?php echo $row_Bilder['bilde2']; ?>" width="80" height="80" border="0"></a></div>  <?php } ?>    </tr> 

.

 

This is almost working.

 

the only thing is that picture nr 1 ($row_Bilder['bilde1') will not show on the page. But picture 2 is working. STRANGE

 

This has been killing me. I need really some help.

 

 

Take a look.

vanvara.net

 

 

 

 

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

if there is a null in the image varialbe it will not display the image but the HTML is still there so you get a image missing x on the browser. Try a n if statement to check that the image exits first if so display it other wise display a default image or don't sent any html.

 

if(row_Bilder[1}(

img src=<?php echo $row_Bilder['bilde1];

} else{

display either a default image or no image.

Link to comment
Share on other sites

on one of my sites I use this;

 

if($row[4]==""){

echo"<td class=\"producttext\"><a href=\"details.php?id=$row[0]&storeID=$storeID&currency=$currency\"><img src=\"../images/savers/image_not_available.jpg\"></a></td>";

}else{

echo "<TD valign=\"top\" class=\"producttext\"><a href=\"details.php?id=$row[0]&storeID=$storeID&currency=$currency\"> <img src=\"../images/savers/$row[4]\"></a> </TD>";

}

 

where row[4] would be my image variable

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.