Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:14:35+00:00 2026-05-30T18:14:35+00:00

I’ve been working on a piece of code that that pulls the name of

  • 0

I’ve been working on a piece of code that that pulls the name of a guild and with it the information of boss/monsters said guild has killed in an online game. There are many many monsters in this game and every one has three difficulty settings. I have managed to get the code to do what i want however it has an enormous amount of copy and paste and ive only done about 1/5 of the total amount of enteries. I really cant think how to make this code less of a giant bloat. This is the code for just one monster for the 3 difficulty settings as you can see it’s alot just for one. there are probably another 60 of these!. Can anybody help me understand better ways to do this. Thanks!

$sql = 'SELECT * FROM `phpbb_profile_fields_data`';

  $result = $db->sql_query($sql);

  while ($row = $db->sql_fetchrow($result))
  {      
    /////////////////////////////////// START - 8 MAN BONETHRASHER
    $normal = '';
    $hard = '';
    $nightmare = '';
    /////// START - CHECK NORMAL
    if ($row['pf_kp_em_no_bonethr'] == '1')
        {
            $normal = '&nbsp;<img src="/styles/subsilver2/theme/images/soap/no.png" />';
        }       
    else if ($row['pf_kp_em_no_bonethr'] == '2')
        {
            $normal = '';
        }       
    else if (is_null($row['pf_kp_em_no_bonethr'])) 
        {
            echo "Boss was set as NULL This should not happen!";
        }
    else
        {
            echo "Sosia messed up go hit him in the face.";
        }
    /////// END - CHECK NORMAL  
    /////// START - CHECK HARD
    if ($row['pf_kp_em_ha_bonethr'] == '1')
        {
            $hard = '&nbsp;<img src="/styles/subsilver2/theme/images/soap/ha.png" />';
        }       
    else if ($row['pf_kp_em_ha_bonethr'] == '2')
        {
            $hard = '';
        }       
    else if (is_null($row['pf_kp_em_ha_bonethr'])) 
        {
            echo "Boss was set as NULL This should not happen!";
        }
    else
        {
            echo "Sosia messed up go hit him in the face.";
        }
    /////// END - CHECK HARD    
    /////// START - CHECK NIGHTMARE
    if ($row['pf_kp_em_kn_bonethr'] == '1')
        {
            $nightmare ='&nbsp;<img src="/styles/subsilver2/theme/images/soap/kn.png" />';
        }       
    else if ($row['pf_kp_em_kn_bonethr'] == '2')
        {
            $nightmare = '';
        }       
    else if (is_null($row['pf_kp_em_kn_bonethr'])) 
        {
            echo "Boss was set as NULL This should not happen!";
        }
    else
        {
            echo "Sosia messed up go hit him in the face.";
        }
    /////// END - CHECK NIGHTMARE   

if ($normal == '' && $hard == '' && $nightmare == '') 
        {

        }
    else
        {
            $template->assign_block_vars('8m_bonethrasher', array(
            'VAR1' => $row['pf_guild_name'],
            'VAR2' => $normal,
            'VAR3' => $hard,
            'VAR4' => $nightmare,
            ));
        }

  }

  $db->sql_freeresult($result);         
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:14:36+00:00Added an answer on May 30, 2026 at 6:14 pm

    I’m still slightly fuzzy at what you are trying to do, but I’ll give helping you out a shot.

    You could probably get away will creating a class that does all of this.

    For example:

    class checks {
    
        public function checkBosses($normalBoss, $hardBoss, $nightmareBoss) {
    
            $difficulties = array();
    
            $difficulties['normal'] = array('boss' => $normalBoss);
            $difficulties['hard'] = array('boss' => $hardBoss);
            $difficulties['nightmare'] = array('boss' => $nightmareBoss);
    
            foreach ($this->difficulties as $difficulty -> $boss) {
                $this->difficulties[$difficulty]['result'] = checkDifficulty($boss['boss'], $difficulty);
            }
    
            $normal = $this->difficulties['normal']['result'];
            $hard = $this->difficulties['hard']['result'];
            $nightmare = $this->difficulties['nightmare']['result'];
    
    
            if ($normal == '' && $hard == '' && $nightmare == '') {
                return null;
            } else {
                return array(
                    'normal' => $normal,
                    'hard' => $hard,
                    'nightmare' => $nightmare,
                );
            }
        }
    
        protected function checkDifficulty($boss, $difficulty) {
    
            if ($difficulty == 'normal') {
                $image = '&nbsp;<img src="/styles/subsilver2/theme/images/soap/no.png" />';
            } else if ($difficulty == 'hard') {
                $image = '&nbsp;<img src="/styles/subsilver2/theme/images/soap/ha.png" />';
            } else if ($difficulty == 'nightmare') {
                $image = '&nbsp;<img src="/styles/subsilver2/theme/images/soap/kn.png" />';
            } 
    
            if ($boss == '1') {
                return $image;
            } else if ($boss == '2') {
                return '';
            } else if (is_null($boss)) {
                echo "Boss was set as NULL This should not happen!";
            } else {
                echo "Sosia messed up go hit him in the face.";
            }
        }
    }
    

    Then all you would need to do is call:

    $checkResult = checks::checkBosses($row['pf_kp_em_no_bonethr'], $row['pf_kp_em_ha_bonethr'], $row['pf_kp_em_kn_bonethr']);
    
    if ($checkResult != null) {
        $template->assign_block_vars('8m_bonethrasher', array(
            'VAR1' => $row['pf_guild_name'],
            'VAR2' => $normal,
            'VAR3' => $hard,
            'VAR4' => $nightmare,
        ));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.