From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Using modulo division to establish a repeating series

Using modulo division to establish a repeating series - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Using modulo division to establish a repeating series

The problem with the mixed arrangements page in the Hansel and Petal site, is that looping through the results of the database query has displayed each item in a separate div. We need to adapt the loop so that four items appear in each div. So we'll have four items going across the page, on each row. It doesn't involve a lot of code, but it does need a little explanation. So let's take a look at the existing code. Go to our code editor, and the loop begins on line 57, and it ends on line 67. Inside there, we've got a div, an unordered list, and one list item. We need some way of adding four items to that unordered list, as we had in the original HTML. So let's analyze what needs to be done. This is the basic structure. Each time the loop runs, you get a div and an unordered list with a single item in it. We need the loop to control the opening and closing tags of the div and unordered list, so that four list items are sandwiched between them. So, the first time that the loop runs, the…

Contents