brown2005 Posted September 8, 2009 Share Posted September 8, 2009 $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 More sharing options...
Jibberish Posted September 8, 2009 Share Posted September 8, 2009 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++; } Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914742 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 no that does not work.. you can see http://www.allinthissite.co.uk/ there. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914743 Share on other sites More sharing options...
Jibberish Posted September 8, 2009 Share Posted September 8, 2009 sorry I put in a sneaky edit. Double check you have what I changed. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914744 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 $row_color = ($row_count % 6 != 0) ? $class1 : $class2; thats what I changed.. and still does not work take a look at http://www.allinthissite.co.uk/ Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914749 Share on other sites More sharing options...
Jibberish Posted September 8, 2009 Share Posted September 8, 2009 I also changed $row_count = 0; to $row_count = 1; change that and your all done. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914751 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 hi mate changed that.. and still a problem Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914754 Share on other sites More sharing options...
Jibberish Posted September 8, 2009 Share Posted September 8, 2009 did you want the image to have the class of last or the <li> tag. as you have it as "<li class='$row_color'> not in the image tag. looking on your website tis giving the 6th <li> the class. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914756 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 yeah it should be the <li> as the last class is just ul#listings li.last { margin-right: 0; } Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914773 Share on other sites More sharing options...
Jibberish Posted September 8, 2009 Share Posted September 8, 2009 Using firebug it looks fine to me http://img245.imageshack.us/img245/6461/labeld.jpg Or am I missing something Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914776 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 take a look at http://www.allinthissite.co.uk/ on the 6th image it is missing the right hand part of the image. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914778 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 i have sorted it. i had #wrapper { width: 964px; margin: 0 auto; } so changed this to #wrapper { width: 974px; margin: 0 auto; } and it appears fine now.. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914783 Share on other sites More sharing options...
Jibberish Posted September 8, 2009 Share Posted September 8, 2009 Yeah was going to say that must be a CSS problem. congrats on getting it sorted. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914787 Share on other sites More sharing options...
brown2005 Posted September 8, 2009 Author Share Posted September 8, 2009 thanks for all your help. Link to comment https://forums.phpfreaks.com/topic/173537-class-is-different-on-6th-image/#findComment-914788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.