hi everyone, I am looking into a small problem I have with a mysql database.
At the moment users can upload upto 4 images per item.
I am using php to display the images from the database, but if a user has only uploaded 2 images
I am getting empty images displaying.

Is there a way to check if a mysql colum has data ? and if it has, display it
the data in each colum is the path to each image stored on the server
For example
itemimage01 (Coloum Name)
http://www.mydomainname.com/path/to/image/image.jpg

I am using the following to get a list of images

<?php 
// build and display image gallery
$sql = mysql_query("SELECT * FROM images WHERE uiid='$uiid'");

$img_list = '';

while($row = mysql_fetch_array($sql)){ 

    $img1 = $row['img1'];   
    $img_list .= "<img src='$img1' width='268' height='269' title='$title' alt='$title'/>";
    }
?>

Then displaying the images using php open and close brackets

Thanks in advance

Change your code to

if (strlen($img1))
    $img_list .= "<img src='$img1' width='268' height='269' title='$title' alt='$title'/>";

or better

if (file_exists($_SERVER['DOCUMENT_ROOT'] . $img1))
    $img_list .= "<img src='$img1' width='268' height='269' title='$title' alt='$title'/>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.