Jump to content

I Need Help


Garetty

Recommended Posts

$a = 0;
$Loop = 1;
if ($ed < 50) {
    // Do some stuff here,
}
	while ($ed > 49) {
		$a++;
		$low = ($ed - 50);
		$ed = $low;
	}
if ($Loop < $a) {
		$Loop++;
		sleep(2);
	}

 

This is some of the code I have...

 

I need it to get so that if Ed's age is less than 50, then it will just do whatever I need it to do. But for how my scripts is set up, I need it to get the exact number of his age sent to my site. But the number has to be less than 50. So I need to know how I can do this using loops and stuff.

 

That's confusing... if you don't understand, read this:

 

I am sending info to my site. In this example, Ed's age.

The number has to be less than 50 to be able to send to my site. I have my site set up so that it will add all the numbers to get the exact age.

Right now, I have it so that if Ed's age is less than 50, it will go ahead and send his age to my site.

But if his age is more than 50, I need to get that number sent to my site, but the number has to be less than 50. So I pretty much have to find out how many times I need to reduce the number by 50, then send 50 to my site however many times it had to reduce. The problem is, I don't know how to get the remaining amount so that I can get the exact amount sent to the site.

 

And I cannot just divide by 2, because Ed is only an example. Say the number was 321. I need the script to subtract 50 from that x times. In this case, 6. So the script will send 50 to my site 6 times. Then I need to know how to get the remaining amount sent to my site.

Link to comment
https://forums.phpfreaks.com/topic/200385-i-need-help/
Share on other sites

as best as I can tell

$age=520;
$remainder=$age%50;  // % gets the remainder of division 
$amount=floor($age/50);   // divide by 50 then round down.  Gets the number of times 50 goes in to the age. 

// loop for each time 50 goes into $age
for($a=0;$a<$amount;$a++)
{
// send 50 to your site
} 
// send remainder to your site

 

Link to comment
https://forums.phpfreaks.com/topic/200385-i-need-help/#findComment-1051607
Share on other sites

$age=321;

if($age>50)

{

$multiplyer=floor($age/50);/number of times 50 was detected

$remainder=$age%50//the remainder

}

You dont need to send 50 to your site multiple times.You only need send the age then do the calculations to know the multiplyer so you can do whatever $multiplyer times then work with the $remainder.

 

 

HTH

Teamatomic

Link to comment
https://forums.phpfreaks.com/topic/200385-i-need-help/#findComment-1051611
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.