you can use switch statements:
switch($priority){
case 000:
code here
break;
case med:
more code
break;
default:
in case none match use default
}
-jack
"Ashley M. Kirchner" wrote:
>
> Is there a better way to write the following snippet:
>
> if ($priority == "000") {
> $fcol="high";
> $pstr .= "<option value=\"000\" selected>High\n";
> $pstr .= "<option value=\"050\">Medium\n";
> $pstr .= "<option value=\"100\">Low\n";
> } elseif ($priority == "050") {
> $fcol="med";
> $pstr .= "<option value=\"000\">High\n";
> $pstr .= "<option value=\"050\" selected>Medium\n";
> $pstr .= "<option value=\"100\">Low\n";
> } else {
> $fcol="low";
> $pstr .= "<option value=\"000\">High\n";
> $pstr .= "<option value=\"050\">Medium\n";
> $pstr .= "<option value=\"100\" selected>Low\n";
> }
>
> I just hate having to repeat pieces of code. This piece here just
> generates a drop down list of items, with the current one being the
> selected one.
>
> AMK4
>
> --
> W |
> | I haven't lost my mind; it's backed up on tape somewhere.
> |____________________________________________________________________
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130
> SysAdmin / Websmith . 800.441.3873 x130
> Photo Craft Laboratories, Inc. . eFax 248.671.0909
> http://www.pcraft.com . 3550 Arapahoe Ave #6
> .................. . . . . Boulder, CO 80303, USA
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]