Jump to content


Photo

Need to get rid of this IF


  • Please log in to reply
2 replies to this topic

#1 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 01 September 2006 - 03:21 PM

I have this function :
<?php
if (! empty($pref['autotip']) && $pref['autotip']==1) {
              $template->set_var('TIP_STATUS1', 'checked');
          } else {
            $template->set_var('TIP_STATUS1', '');
          }

          if (! empty($pref['autotip']) && $pref['autotip']==0) {
              $template->set_var('TIP_STATUS2', 'checked');
          } else {
              $template->set_var('TIP_STATUS2', '');
          }

          $template->set_var('PREF_MNGR', $PREF_MNGR);

          if (isset($this->update) && $this->update)
          {
             $template->set_var('UPDATE_MSG',
                                 $this->getMessage('PREFERENCES_UPDATED')
                               );
          }
          else $template->set_var('UPDATE_MSG', '');

          $themeTemplate->set_var('CONTENT_BLOCK',
                                  $template->parse('mblock', 'mainBlock'));

          $template->parse('contentBlock', 'fh1');

          $themeTemplate->parse('cnblock', 'contentBlock');
          $themeTemplate->parse('mmblock', 'mmainBlock');
          $themeTemplate->pparse('output', 'fh');

      }
?>
And I want 'autotip' to always == 1 for 'TIP_STATUS1' i.e $template->set_var('TIP_STATUS1', 'checked');
So it will not have to get info from the form.

And I always want it to be like that so it never really needs to be updated.  And if it never really needs to be updated it won't need to be stored in the database.

So could someone help me re-write this please.  Many Thanks

#2 scottybwoy

scottybwoy
  • Members
  • PipPipPip
  • Advanced Member
  • 532 posts
  • LocationUK

Posted 05 September 2006 - 12:43 PM

*PROBE* Anyone know haow to help me on this one ?

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 September 2006 - 12:57 PM

I may be a little confused, by if you don't want that status to change, why not just comment out that first if/else block?

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users