## difficult calculation

Moderators: egami, macek, gesf

shewien
New php-forum User
Posts: 13
Joined: Wed Sep 25, 2002 6:13 am
Here's my problem: every 50th visitor gets a present. But I don't feel like emptying my table everytime I reach 50. Visitor nr. 100 or 2050 should also get the message: you are visitor 50! And visitor nr. 103 should get: you are nr.3 !

I wrote down how i want to calculate this:
result1 = actual visitor number / 50
result2 = result1 - natural number
result3 = result2 / 2
result4 = result3 * 100

with numbers, for visitor nr. 103:
result1 = 103 / 50 (=2.06)
result2 = 2.06 - 2 (=0.06)
result3 = 0.06 / 2 (=0.03)
result4 = 0.03 * 100 (=3)

Does anyone know if such a calculation is possible?

mjr
New php-forum User
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am
Contact:
shewien wrote:Here's my problem: every 50th visitor gets a present. But I don't feel like emptying my table everytime I reach 50. Visitor nr. 100 or 2050 should also get the message: you are visitor 50! And visitor nr. 103 should get: you are nr.3 !

I wrote down how i want to calculate this:
result1 = actual visitor number / 50
result2 = result1 - natural number
result3 = result2 / 2
result4 = result3 * 100

with numbers, for visitor nr. 103:
result1 = 103 / 50 (=2.06)
result2 = 2.06 - 2 (=0.06)
result3 = 0.06 / 2 (=0.03)
result4 = 0.03 * 100 (=3)

Does anyone know if such a calculation is possible?

there is a `%' operator - it is a reminder from division. so:

Code: Select all

``\$visitorN=\$actuad_visitor_count%50;if(\$result1==0{  echo "You are premium visitor!"}else{  echo "you are visitor #\$visitorN";}``
With best regards,
Cyril Kobets