php - Counter inside while loop every X times increase -


I'm not sure how to work this question, but I currently have loop output in & Lt; Li & gt; ; & Lt; / Li & gt; .

Let's say there are 35 rows and I want to increase the counter every five times.

Then the output will be something like this. - name - 1 name - 2 name - 2 name - 2 name - 2 name - 2 name - 3 name - 3 name - 3 name - 3 Name - 3 Name - 4 Name and so on ... I tried to count in the loop and compare the number to see if it is less than five And if not then to increase it, but I know it's not right. ($ Stmt-> Fatch ()) {$ HTML. = "& Lt; li Data-id = '$ id' data-name = '$ name' & gt; $ count name & lt; / li & gt;"; }

To try to clarify this ... basically I would like to run a counter variable. Starting from 1, but every fifth time through the loop, I would like to increase this count variable from one.

$ count = $ rows = 0; While ($ stmt-> fetch ()) {if ($ rows% 5 == 0) $ count ++; $ Rows ++; $ HTML = "& Lt; li Data-id = '$ id' data-name = '$ name' & gt; $ count name & lt; / li & gt;"; }

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -