0
votes

The code bellow shows data from a mysql table and it echos images paths associated with an image in an image folder but the problem arises when the data for the image path is empty their appears an empty box which I do not want. I want the empty image src box not to appear and i want that empty space to not appear as well. Basically i don't want rows of empty spaces to appear when their is no data/value in the mysql table and I do not want the image src box to appear with a blank box. The image path is called name. I used a tiny bit of javascript code below but it doesn't work.

just in case you're confused the img src button on top is linked to a light box so here is a simple img src code you can use for an example

    <img src="a/<?=$name ?>" />

Sorry everyone none of the codes below work. It all has to do with the msyql fetch and add null to the end of the msyql query. If you seen ways to do it in php it malfunctions most of the time.

HERE IS AN examaple. I hope you appreciate it.

   SELECT pm.mid, pm.size, pm.timestamp, pm.message, pm.name, pm.who, header.id,   header.username
     FROM pm, header
     WHERE pm.name IS NOT NULL ORDER BY pm.id2
2

2 Answers

0
votes

Css selectors work like this: img[src=""]

0
votes

Try this around your image output code:

<?php                 
if( $name != '' ) {
?><a href="a/<?=$name ?>" rel='lightbox'> <img src=  "a/<?=$name ?>" width='150' height='100'   class='img' id='img'" >  </a> <?php
}
?>

If you want to check the file exists as well as just the database field being blank, check out file_exists()