You are here: Re: Anoying problem with multiple 'elseif' variations... « PHP Language « IT news, forums, messages
Re: Anoying problem with multiple 'elseif' variations...

Posted by Hello on 10/15/79 11:21

Why not use a SWITCH statement, would be cleaner and much easier to read.
Plus, if you position them right then you can skip a few break statements
and make a code a bit compressed.

"Peter Butler" <peterbutler@iafrica.com> wrote in message
news:y-CdndhlJdoeqkXfRVn-pg@is.co.za...
> OK, lets see...
>
> I have 10 text boxes to enter keywords into a form page (The master search
> page)
>
> These boxes are either set or not set when passed to the result page as
> set
> or unset variables.
>
> Depending on which variables have been set, the set variables are used to
> formulate the query.
>
> I have got this to work perfectly... but I am convinced that I'm using the
> dinosour method. ie.:
>
> if ($a==a && $b==a && $c==a && $d==a && $e==a && $f==a && $g==a && $h==a
> &&
> $i==a && $j==a)
> { do thing AA}
> elseif ($a!=a && $b==a && $c==a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing BB}
> elseif ($a==a && $b!=a && $c==a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing CC}
> elseif ($a==a && $b==a && $c!=a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing DD}
> elseif ($a==a && $b==a && $c==a && $d!=a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing EE}
> elseif ($a==a && $b==a && $c==a && $d==a && $e!=a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing FF}
> elseif ($a==a && $b==a && $c==a && $d==a && $e==a && $f!=a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing GG}
> elseif ($a==a && $b==a && $c==a && $d==a && $e==a && $f==a && $g!=a &&
> $h==a
> && $i==a && $j==a)
> { do thing HH}
> elseif ($a==a && $b==a && $c==a && $d==a && $e==a && $f==a && $g==a &&
> $h!=a
> && $i==a && $j==a)
> { do thing II}
> elseif ($a==a && $b==a && $c==a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i!=a && $j==a)
> { do thing JJ}
> elseif ($a==a && $b==a && $c==a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j!=a)
> { do thing KK}
>
> /* then different combos of two's */
> elseif ($a!=a && $b!=a && $c==a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing BB}
> elseif ($a!=a && $b==a && $c!=a && $d==a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing BB}
> elseif ($a!=a && $b==a && $c==a && $d!=a && $e==a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing BB}
> elseif ($a!=a && $b==a && $c==a && $d==a && $e!=a && $f==a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing BB}
> elseif ($a!=a && $b==a && $c==a && $d==a && $e==a && $f!=a && $g==a &&
> $h==a
> && $i==a && $j==a)
> { do thing BB}
> etc, etc, etc...........
>
> /* then different combos of threes */
> elseif ($a!=a && $b!=a && $c!=a...
> {do thing wada-wada...
> elseif ($a!=a && $b!=a && $c==a...
> {do thing wada-wada...
> elseif ($a!=a && $b!=a && $c==a...
> {do thing wada-wada...
> etc, etc, etc...........
>
> /* then different combos of fours */
> elseif ($.......................................................
> elseif ($.......................................................
> elseif ($.......................................................
> etc, etc, etc...........
>
> /* then different combos of fives */
> elseif ($.......................................................
> elseif ($.......................................................
> elseif ($.......................................................
> etc, etc, etc...........
>
> /* then different combos of sixes */
> elseif ($.......................................................
> elseif ($.......................................................
> elseif ($.......................................................
> etc, etc, etc...........
>
> /* then different combos of sevens */
> elseif ($.......................................................
> elseif ($.......................................................
> elseif ($.......................................................
> etc, etc, etc...........
>
> /* then different combos of eights */
> /* then different combos of nines */
>
> /* until... three thousand six hundred and forty-nine lines of code later
> we get to make*/
> elseif ($a!=a && $b!=a && $c!=a && $d!=a && $e!=a && $f!=a && $g!=a &&
> $h!=a
> && $i!=a && $j!=a)
> { do thing XXXXXXX}
>
> - OK... For those eagle eyes out there... I actually have 14 different
> fields in which to set variables... two pairs of which are grouped
> together
> as max/min values,
> but I do really have 3649 lines of stuff that is slowing down my DUAL
> PIII
> 500 on saves.
>
> This can't be the right way... really???
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация