Hi,i have a small problem with the following...
a users posts a vehicle to the database, the form allows for posting with 3 images.
when i display the form using a while loop i need to display the images, my problem is that i want to check 3 images 0r 2 images or 1 image was posted, if 3 was posted then show 3 if 2 was posted then show 2 etc etc,
im new to this so i dont know if i am explaining myself correctly,
my code is bellow

while ($row = mysql_fetch_assoc($query))

{	echo 
	"<div style='border:solid 1px #cccccc; float:left; width:700px; height:150px; margin:10px;'>
			<table cellpadding='0' cellspacing='0' border='0'>
            <tr>
			<td width='200px'>
			<div>
			<a href='cars/$row[image1]' rel='lightbox' title='$row[make] $row[model]' ><img src='cars/{$row['image1']}' width='200px' height='150px'; border='0'/></a>
			</div>
			</td>
            <td valign='top' style='padding:0px 5px 0px 0px; font-size:12px; width:280px; background-color:#ffffff;'>
            <div style='text-align:left; padding:5px;'>
			  <div style='text-decoration:underline; font-size:13px; font-weight:bold;'>{$row['make']}&nbsp;{$row['model']}</div>
			  <div style='height:108px; padding-top:2px;'>{$row['description']}</div>
			  <div>Price: R.{$row['price']} | Colour: {$row['color']} | Year: {$row['yearmodel']}</div>
            </div>
			
            </td>
            <td width='120px'>
<!-- here i need to first check if the variable $row[image2] contains an image other was its shows that icon of no image found -->
            <img src='cars/$row[image2]' width='120px' height='90px'; border='0'/>
            </td> 
            <td width='120px'>
<!-- here i need to first check if the variable $row[image3] contains an image other was its shows that icon of no image found -->
            <img src='cars/$row[image3]' width='120px' height='90px'; border='0'/>
            </td>
            </tr>
            </table>
	</div>"; 
}

i will really appreciate any assistance as i am trying to build my first site, wish me luck!

check this:

while ($row = mysql_fetch_assoc($query))

{	echo 
	"<div style='border:solid 1px #cccccc; float:left; width:700px; height:150px; margin:10px;'>
			<table cellpadding='0' cellspacing='0' border='0'>
            <tr>
			<td width='200px'>
			<div>
			<a href='cars/$row[image1]' rel='lightbox' title='$row[make] $row[model]' ><img src='cars/{$row['image1']}' width='200px' height='150px'; border='0'/></a>
			</div>
			</td>
            <td valign='top' style='padding:0px 5px 0px 0px; font-size:12px; width:280px; background-color:#ffffff;'>
            <div style='text-align:left; padding:5px;'>
			  <div style='text-decoration:underline; font-size:13px; font-weight:bold;'>{$row['make']}&nbsp;{$row['model']}</div>
			  <div style='height:108px; padding-top:2px;'>{$row['description']}</div>
			  <div>Price: R.{$row['price']} | Colour: {$row['color']} | Year: {$row['yearmodel']}</div>
            </div>
			
            </td>
            <td width='120px'>";

if($row["image1"]!="")
$image1=$row["image1"];
else
$images1="../no_im_found.jpg";// your image with path.
if($row["image2"]!="")
$image2=$row["image2"];
else
$images2="../no_im_found.jpg";// your image with path.
if($row["image3"]!="")
$image3=$row["image3"];
else
$images3="../no_im_found.jpg";// your image with path.
echo "<!-- here i need to first check if the variable $image2 contains an image other was its shows that icon of no image found -->
            <img src='cars/$image2' width='120px' height='90px'; border='0'/>
            </td> 
            <td width='120px'>
<!-- here i need to first check if the variable $image3 contains an image other was its shows that icon of no image found -->
            <img src='cars/$image2' width='120px' height='90px'; border='0'/>
            </td>
            </tr>
            </table>
	</div>"; 
}

Thank you soooo much, it helped.

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.