Jump to content

Math using IF statement syntax error


vbcoach

Recommended Posts

Hello all.  Having trouble with doing an IF statement using a math operator.  Seems simple enough, but I keep getting a syntax error.

 

I have a sports league, who's fees are based upon the number of (extra) players on a team.

    $intPlayers is a variable number derived by a loop of the number of registered players on a given team.

    $intBsize is the base league size given based upon the league registered (2, 4, or 6)

 

I am trying to come up with a mathmetical PHP statement that will determine if the number of (extra) players over the "base" number.  Once that happens, I can charge a fee per player over the team base amount allowed.  For example, if a 6's league registers 8 players, they need to pay for those additonal two players.

 

So here is my code with the syntax error:


$plyrCount = $intPlayers - $intBsize
  {if $plyrCount<0 then $plyrCount = '0'}

$xtraPlyrs = ($plyrCount * 40)

 

I have tried a bunch of variations, but nothing seems to work.  If the value of $plyrCount is a negative number, then set $plyrCount to zero.

 

Can anyone help please?

Link to comment
https://forums.phpfreaks.com/topic/263974-math-using-if-statement-syntax-error/
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.