Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

difficult calculation

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

difficult calculation

Postby shewien » Fri Sep 27, 2002 3:59 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?
User avatar
shewien
New php-forum User
New php-forum User
 
Posts: 13
Joined: Wed Sep 25, 2002 6:13 am

Re: difficult calculation

Postby mjr » Fri Sep 27, 2002 6:47 am

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";
}
mjr
New php-forum User
New php-forum User
 
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.