Link to home
Start Free TrialLog in
Avatar of Mike Waller
Mike WallerFlag for United States of America

asked on

adjust php code

I have the following php code and after the first two blog posts, a sales banner image appears below them.  Below that sales banner image display the remaining blog posts.  However, the image that I'm displaying for those bottom blog posts needs to be a different image.  Any idea how I would do that?
<div class="post<?php if (($counter % 2) == 0) { echo ' last'; } ?>">

			<img src="/images/New-Sales-Banner-$395.png" width="289px;" height="347px;" alt="" title="" align="center" border="0" />
			
			<div class="dotted-line"></div> 
	        </div><!-- /.post -->
		
            <?php if ( $counter == 2 ) { ?>
			
			<div style="margin-bottom: 20px;margin-top: -10px; float:left">
			<a href="/"><img src="/images/DPR-local-sales-banner-b.png" alt="" title="" width="619" height="160" class="noflashbanner" /></a></div>
			<?php } ?>
                                                
        	<?php endwhile; else: ?>            
        
			<?php endif; $counter = 0; ?>

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Line 11.  Replace the information inside the quotes.

src="/images/DPR-local-sales-banner-b.png"
Avatar of Mike Waller

ASKER

That is the banner graphic that shows up below the top two blog post images.  So I need to add another image below that banner graphic.  so visually, it's like this:

A  A
  B
C  C
C  C
C  C

So, A, B and C are all different image graphics
Actually, I missed adding in some of that code above.  Below is the php code I have.  I changed out the name of the banners to reflect what I'm needing.  So currently only banner A and B is showing up on the page, but I'm not sure where to place banner C so that is shows up like this:

A  A
  B
C  C
C  C
C  C
<?php if (have_posts()) : $counter = 0; ?>
<?php while (have_posts()) : the_post(); $counter++; ?>                                                                
        <div class="post<?php if (($counter % 2) == 0) { echo ' last'; } ?>">

	<img src="/images/A.png" width="289px;" height="347px;" alt="" title="" align="center" border="0" />
			
	<div class="dotted-line"></div>
			
	</div><!-- /.post -->
		
            <?php if ( $counter == 2 ) { ?>			
			<div style="margin-bottom: 20px;margin-top: -10px; float:left">
			<a href="/"><img src="/images/B.png" alt="" title="" width="619" height="160" class="noflashbanner" /></a></div>
	    <?php } ?>
                                                
<?php endwhile; else: ?>            
        
<?php endif; $counter = 0; ?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Ray.  So the two A's represent two banner graphics.  B is a different banner graphic and C is a different banner graphic.

In total, I have 2 A banner graphics, 1 B banner graphic, and 6 C banner graphics.  So I need to loop through each of the 8 blogs that I have and display those graphics in the order like this:

A  A
  B
C  C
C  C
C  C
okay, so I added in each image however, the right side image above the B banner graphic is missing.  Any idea on that?
<?php $imgArray = array('New-Sales-Banner-$395.png','New-Sales-Banner-$395.png','DPR-local-sales-banner-b.png','New-Sales-Banner-$295.png','New-Sales-Banner-$295.png','New-Sales-Banner-$295.png','New-Sales-Banner-$295.png','New-Sales-Banner-$295.png','New-Sales-Banner-$295.png');
	if (true /*have_posts()*/) { $counter = 0;
	while ($counter < 9 /*have_posts()*/) { /*the_post();*/  $counter++;
		if ( $counter == 2 ) { ?>		
		<div style="margin-bottom: 20px;margin-top: -10px; float:left;">		
		<a href="/"><img src="/images/<?php echo $imgArray[$counter]; ?>" alt="" title="" width="619" height="160" class="noflashbanner" /></a>		
		</div>		
		
			<?php continue;} ?>
		<div class="post<?php if (($counter % 2) == 0) { echo ' last'; } ?>">

		<img src="/images/<?php echo $imgArray[$counter]; ?>" width="289px;" height="347px;" alt="" title="" align="center" border="0" />
			
		<div class="dotted-line"></div>
			
		</div><!-- /.post -->
                                                
<?php } ?>            
        
<?php } $counter = 0; ?>

Open in new window

I do not know what your html or css may be doing to limit the width, or give other settings to make your images show 2 in a row, since you say that the  New-Sales-Banner-$295.png  or "C" images are in their proper places, 2 by 2, then I will suggest you try and change the code

change line 3 -
if (true /*have_posts()*/) { $counter = 0;

to

if (true /*have_posts()*/) { $counter = -1;

Zero to minus one, I did not change it in the first code, because I thought that the counter may be used in other ways, as a database access or in the code for  the_post($counter);
please see if you can follow what the code is doing, and why if you start it at $counter = -1; , , the first time it is used, it has been changed to zero
Perfect.  Thanks Ray!