You dont need to use an if/else... it would be something like
PHP Code:
$sql = $db->query_first("select * from " . TABLE_PREFIX . "userteam WHERE userteamid=$teamid AND WHERE title=$teamtitle");
$db->query_write("UPDATE " . TABLE_PREFIX . "user SET teamtitle = '$teamtile' WHERE $teamid=userteamid AND WHERE title=$teamtitle");
$db->query_write("UPDATE " . TABLE_PREFIX . "user SET teamtitle = 'NULL' WHERE userteamid=$teamid");
1 - read teh fields in the db
2 & 3 - update those fields
You can probably combine those last two queries into one like in your read query...