# My minds gone blank - Calculating

5 replies to this topic

### #1 Rehehelly

Rehehelly
• New Members
• Newbie
• 4 posts
• LocationPortsmouth, England

Posted 18 March 2006 - 01:23 AM

Okay, so.. i'm tired, probably not the best time to be doing this, but.. maeh.

Say I have a list of seconds to get to a game level,

Level 1. 1000
Level 2. 2000
Level 3. 3000
Level 4. 4000
and so on, if I wanted to calculate how many seconds to get from level 1 to level 50. How would I go about doing that?

I told you my mind has gone blank >.<

Thanks
~Dan

### #2 Spixxx

Spixxx
• Members
• Member
• 29 posts

Posted 18 March 2006 - 01:46 AM

I would assume 50,000 ... ?

### #3 Rehehelly

Rehehelly
• New Members
• Newbie
• 4 posts
• LocationPortsmouth, England

Posted 18 March 2006 - 02:17 PM

I really should have clarified that. I mean like

Add level 1, level 2, level 3, level 4, level 5, level 6, level 7 etc. till you get to level 50.

### #4 wildteen88

wildteen88
• Staff Alumni
• 10,482 posts
• LocationUK, Bournemouth

Posted 18 March 2006 - 02:35 PM

Then it'll be a woping total of 1,275,000 secounds!!

This how I worked it out:
```<?php
\$s = "\\$sec = ";
for(\$i = 1; \$i < 50; \$i++)
{
\$s .= (\$i*1000).'+';
}

\$s .= "50000;";

echo eval(\$s);
echo \$sec;

?>```

### #5 Rehehelly

Rehehelly
• New Members
• Newbie
• 4 posts
• LocationPortsmouth, England

Posted 18 March 2006 - 03:32 PM

I love you.

### #6 Barand

Barand
• Moderators
• Sen . ( ile || sei )
• 18,022 posts

Posted 19 March 2006 - 09:15 AM

Wildteen,

Seems a roundabout way of doing it !

```\$sec = 0;
for (\$i=1; \$i <= 50; \$i++) {
\$sec += \$i * 1000;
}
echo \$sec;```

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.