Customizing SMF > SMF Coding Discussion

Combining select box breaks

(1/1)

hcfwesker:
smf 2.0.2

kind of hard to explain what im looking for.  I've got this feature,  and members can select from 4 different select boxes, each with the same information.  Each select box has 37 options, again all 4 boxes have the same 37 options to select from.  This works, but it just adds so much to the file this was edited in and was wondering if there was a cleaner way to do it.

Example:

just 2 of the select boxes i posted here.  one labeled $m1mainp1 , and the next $m1mainp2


--- Code: --- switch($m1mainp1)
{
case 0:
break;

case 1:
break;

case 2:
break;

case 3:
break;

case 4:
break;

case 5:
break;

case 6:
break;

case 7:
break;

case 8:
break;

case 9:
break;

case 10:
break;

case 11:
break;

case 12:
break;

case 13:
break;

case 14:
break;

case 15:
break;

case 16:
break;

case 17:
break;

case 18:
break;

case 19:
break;

case 20:
break;

case 21:
break;

case 22:
break;

case 23:
break;

case 24:
break;

case 25:
break;

case 26:
break;

case 27:
break;

case 28:
break;

case 29:
break;

case 30:
break;

case 31:
break;

case 32:
break;

case 34:
break;

case 35:
break;

case 36:
break;

default:
fatal_error($txt['brawl_main1'],false);
break;
}
switch($m1mainp2)
{
case 0:
break;

case 1:
break;

case 2:
break;

case 3:
break;

case 4:
break;

case 5:
break;

case 6:
break;

case 7:
break;

case 8:
break;

case 9:
break;

case 10:
break;

case 11:
break;

case 12:
break;

case 13:
break;

case 14:
break;

case 15:
break;

case 16:
break;

case 17:
break;

case 18:
break;

case 19:
break;

case 20:
break;

case 21:
break;

case 22:
break;

case 23:
break;

case 24:
break;

case 25:
break;

case 26:
break;

case 27:
break;

case 28:
break;

case 29:
break;

case 30:
break;

case 31:
break;

case 32:
break;

case 34:
break;

case 35:
break;

case 36:
break;

default:
fatal_error($txt['brawl_main2'],false);
break;
}
--- End code ---

Is there anyway to combine these, since they both have the same select numbers?  Like 'and' statements like ||  , but still add different selected values to the databse



live627:
Case statements that do the same thing within a single switch can be combined, like case 0: case 2:

Could loop through them all using a foreach .

IchBin™:
Are you going to be doing something different in each case? What exactly are you doing? I could think of different ways to do this, but I have no idea how you are handling the selection.

Navigation

[0] Message Index

Go to full version