MySQL query result, show only 5 results per line, after 5 are shown, start a new line.
Posted on 2005-03-17
How would I go about looping the results of a query to only show 5 results per line in my HTML? For example, There are 10 entries in the database table, I need to retrieve those, and then display 5 entries on each line of my template.... something like:
Row 1, Row 2, Row 3, Row 4, Row 5 (start a new line afterwards)
Row 6, Row 7, Row 8, Row 9, Row 10
How can I go about that? I know it's possible, I've seen it done numerous times. I'd also like to have a "default content" if the number of rows is not divesible by 5. Like if I had only 8 rows, I'd like to have a to "take their place".