I have stories (some with images) displayed through a repeating region. Data of stories and image paths from MySql.
Stories with no image have a blank image frame next to it, but only on MS Explorer. I thought I had this resolved using a variable style. All Mac browsers look fine so dose Win FireFox.

What I want to do is write an "if" statement pertaining to the whole image script, but can't figure it out. Something like? Except I'd like it to work.:)

<?php
if($row_rsSports['imagepath']=="") { 
} else { 
<a href="<?php echo $row_rsSports['imagepath']; ?>" rel="lightbox[]" title="<?php echo $row_rsSports['imagecaption']; ?>"> <img style=""  src="<?php echo $row_rsSports['imagepath']; ?>" class="<?php echo $class; ?>" /> </a> ; 
}
?>

my existing code


Style

.imgright1{
	float: right;
	padding-left: 5px;
	padding-bottom: 5px;
	padding-top: 5px;
	max-width: 50px;
	max-height:80px;
	border: 0px;

Repeat Region

  <?php do { ?>
            
                 
              <p align="center" class="style29"><?php echo $row_rsSports['Headline']; ?></p>
              
                   <p align="justify" class="style17"><strong>
                   
                   <?php

				if($row_rsSports['imagepath']=="") { 
				  $class="noclass";
				} else { 
				   $class="imgright1"; 
				}
				?>
                   
                    <a href="<?php echo $row_rsSports['imagepath']; ?>" rel="lightbox[]" title="<?php echo $row_rsSports['imagecaption']; ?>"> <img style=""  src="<?php echo $row_rsSports['imagepath']; ?>" class="<?php echo $class; ?>" /> </a> 
					
					
					
					
					<?php echo $row_rsSports['Bold1']; ?></strong><?php echo $row_rsSports['SpStory1']; ?><br />
                
              <strong><?php echo $row_rsSports['Bold2']; ?></strong> <?php echo $row_rsSports['SpStory2']; ?></p>
              <p align="justify" class="style17">&nbsp;</p>
              <?php } while ($row_rsSports = mysql_fetch_assoc($rsSports)); ?><p>&nbsp;</p>

Thank You

Well, firstly all of these things <?php echo $something ?> can be replaced by <?=$something?> . Aside from that just create an image with a grey border and nothing else(maybe a white background), call it blank and then make the image src "blank.jpg" or whatever you name it. Changing the class doesn't change the fact that there will be a broken image.

Thanks for the reply and the tip Shawn.
Yes I realize changing the class doesn't solve a broken link. That's why I was asking for help to include the whole image script in an "if" statement.

Anyway I just figured it out and am in the process of updating my live files.

<?php
			   if ($row_rsSports['imagepath'])
			   {
			   	echo "<a href=\"" . $row_rsSports['imagepath'] ."\" rel=\"lightbox[]\" title=\"" . $row_rsSports['imagecaption'] ."\">";
			   	echo "<img style=\"margin:0px 0px 0px 0px\"  src=\"" . $row_rsSports['imagepath'] . "\" alt=\"\"  border=\"0\" class=\"imgright1\"/>"; 
			   	echo "</a>";
			   } 
               ?>
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.