# Solved: if a number can be divided by 5 then... (PHP)



## DrP (Jul 23, 2005)

I'm trying to add a 
after every 5th result from MySQL. I need something like:

for each result:
if (xxx can be divided by 5) {
insert a line break
}
then increase xxx by 1

I've forgotten how I make the divide by 5 statement! How do I do this?
e.g. if (xxx / 5) returns true no matter what xxx is.
Thanks for the help,


----------



## GCDude (Apr 1, 2005)

if (xxx / 5) returns true, as you do not have a comparison in there, its basically doing

if (number) which is always true.

What you need is to use modulus, like so
if(xx % 5 = 0)


----------



## Gibble (Oct 10, 2001)

Something like...

```
for i = 1 to n
  response.write i
  if (i % 5 = 0) resopnse.write "
"
next
```


----------



## DrP (Jul 23, 2005)

Sorted, like so:
if (($count % 5) == 0) {
echo "
";
}
Thanks for your help!


----------



## covert215 (Apr 22, 2006)

so do you have what you want?

if so, mark it solved


----------



## DrP (Jul 23, 2005)

Will do, but you seem to have lost your manners...


----------

