Jump to content


Photo

Images with NULL value in MySql


  • Please log in to reply
2 replies to this topic

#1 Kai74

Kai74
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 07 May 2004 - 12:14 AM

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








#2 Milshak

Milshak
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 May 2004 - 07:08 PM

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.

#3 Milshak

Milshak
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 May 2004 - 07:10 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users