I’m making a forum in PHP. I have to display all forum categories in a table, and to do so, I have used a while loop. However, I want to have only 3 td’s in every table row. To loop through the categories, I’m using a while loop with the query, so I don’t think I can use modulus here.
Share
Why can’t you use modulus? Just add a counter somewhere, and if it hits
% 3 == 0reset the counter and do your stuff.You might need to do some extra if’s for first and last and stuff like that, but there is no reason not to use a modulo with a while.