Jump to content

Need a little help :S


Nytemare

Recommended Posts

I'm developing a browser based RTS game, and am having a little trouble. To explain my problem a little I'll post some code snippets.

 

Currently I have a "premium" function, that adds 750 morale to the user as long as they have remaining premium time left. Currently the function these snippets are in a PHP file where a different PHP file calls the function. This code tells my MySQL database to add 750 in the 4th row (which we're going to name as "morale" if the user is premium.

$row=mysql_fetch_row($result); if ($is_premium) $row[4]+=750;

 

This code states if the morale is over 100, then subtract 100, divide by 100, then divide by 40. if the morale is under 100 then it only divides by 100:

if ($row[4]>100) $m=1+($row[4]-100)/100/40; else $m=$row[4]/100;

 

My problem is, I need to add an if statement like this:

if ($is_premium) AND //I'm not sure how to do an "and" statement, help would be appreciated on this as well\\
     if ($row[4]>100) $m=1+($row[4]-850)/100/40; else $m=$row[4]-750/100;
else //if the $is_premium is false\\ THEN
if ($row[4]>100) $m=1+($row[4]-100)/100/40; else $m=$row[4]/100; 

Link to comment
https://forums.phpfreaks.com/topic/133946-need-a-little-help-s/
Share on other sites

Seems to give me a parse error though :S, any idea?

 

EDIT: Parse error: syntax error, unexpected T_ELSE

Yes, my misreading your original code

if ($is_premium) {
   if ($row[4]>100) {
      $m=1+($row[4]-850)/100/40;
   } else {
      $m=$row[4]-750/100;
} else {
   if ($row[4]>100) {
      $m=1+($row[4]-100)/100/40; 
   } else {
      $m=$row[4]/100; 
   }
}

Link to comment
https://forums.phpfreaks.com/topic/133946-need-a-little-help-s/#findComment-697296
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.