lundi 2 novembre 2015

If Else statement when there are more than two parameters

I've a table name with 3 and 4 fields and I'm gonna use if statement for these tables. currently this following code is working well when there are only two parameters but if its more than two I don't know how to use it.

if ($history->getPsychological()) {
    if($history->getPsychological() == 'Polymenore'){
        $psychological = "Polymenore";
        echo "<img height=\"30\" src=\"images/polymenorrhea.png\" width=\"250\" />\n";
    } else {
        $psychological = "Oligomenore";
        echo "<img height=\"30\" src=\"images/oligomenorrhea.png\" width=\"250\" />\n";
    }
}

In above code, if psychological is Polymenore then it will show its image, else it will show Oligomenore.

I mean, its two fields, 1: Polymenore 2: Oligomenore and it's working well.

so, here is my question,

If there are more than two fields, I mean like 3 and 4 fields, how can I use it into above code:

For example:

How to use it with 3 fields

psychological with 1: A 2: B 3: C

and How to use it with 4 fields

psychological with 1: A 2: B 3: C 4: D

Thanks in advance..

Aucun commentaire:

Enregistrer un commentaire