sark9012
sark9012

Reputation: 5737

if statement OOP

I have the following code

/* Errors exist, have user correct them */
  if($form->num_errors > 0)
  {
     return 1;  //Errors with form
  }
  /* No errors, add the new account to the */
    else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype))
    {
        return 0;  //New user added succesfully
    }
    else
    {
    return 2;  //Registration attempt failed
    }

I want to add the following to it

$databases->addLeagueTable($name)

This should happen at the same time as addLeagueInformation. Any ideas?

Edited, will this work?

else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype)
                                            && $databases->addLeagueTable($name) && $_SESSION['players'] == $subplayers && $comp_name =     
                                            "$format_$game_$name_$season" && $_SESSION['comp_name'] = $comp_name)

Upvotes: 1

Views: 436

Answers (1)

Amy B
Amy B

Reputation: 17977

You should really stay consistent with indentation, it makes code much easier to read.

Anyway:

// Errors exist, have user correct them
if ($form->num_errors > 0)
{
    return 1;  // Errors with form
}
// No errors, add the new account to the
else if ($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype)
    && $databases->addLeagueTable($name))
{
    return 0;  // New user added succesfully
}
else
{
    return 2;  // Registration attempt failed
}

Upvotes: 1

Related Questions