Jump to content

class is different on 6th image.


brown2005

Recommended Posts

						$class1 = "";
					$class2 = "last";

					$row_count = 0; 

						for($i=1; $i<=49; $i++){
						  
							$row_color = ($row_count % 6) ? $class1 : $class2;

							echo"<li class='$row_color'><a href='' class='img'><img src='images/8.jpg' /></a><a href=''>Element Fusion</a></li>";

							$row_count++;

						}

 

this will print 6 images and then start a new line, but i want the 6th image to have the class last, so how can i change the code above to work.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/
Share on other sites

Try changing it to

 

                  $class1 = "";
                  $class2 = "last";
                     
                  $row_count = 1;
                     
                     for($i=1; $i<=49; $i++){
                      
                        $row_color = ($row_count % 6 != 0) ? $class1 : $class2;
                     
                        echo"<li class='$row_color'><a href='' class='img'><img src='images/8.jpg' /></a><a href=''>Element Fusion</a></li>";
                           
                        $row_count++;
                                    
                     }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.