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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.