![]() |
Adding a [CSS] class every 3rd result
Hello all, new to PHP so please, bare with me.
I'm trying to add a class to every third result of a mySQL query. I've tried to figure it out but have had no luck. PHP Code:
Any help or guidance would be greatly appreciated. Thanks in advance. |
Just count as you go and use an "if" to do something every 3rd, so am using the modulo operator to find out if it's the the 3rd, or is divisiable by 3 to echo the line with the class, or if it's false it echo's the line without the ADDCLASSHERE
PHP Code:
|
Here is a way that makes it so that you don't have to have two lines of the same HTML. Makes it easier to maintain. maeltar's code is correct though and will work although it looks like the conditions might be backwards.
PHP Code:
|
| All times are GMT. The time now is 06:37 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0