Main Content

Displaying data at 5 items per line on a web page

Archive - Originally posted on "The Horse's Mouth" - 2006-08-14 05:27:32 - Graham Ellis

If you want to display a list of items in (say) 5 columns on a web page, use a table. A loop in PHP will let you generate all the table cells very easily, then add in a little extra code to deal with:
  a) The very first cell (you need to open table and row)
  b) Every fifth cell (you need to start a new row) and
  c) The very last cell (you need to pad out the last row and close the table).

Like an example?
  Working demonstration here
  Source code here