Jump to content

elseif


hyster

Recommended Posts

is there a better way of coding this using arrays? ive never had a use for them b4

the if and the else statment is ok but its the elseif that i think i can put into an array ut what i tryed didnt work.

 

what id like to do

$loc = array('HDD', 'APRIL 2011', 'WHITE VISTA',  'NEW 1.5 TB', 'UNVALIDATED')

elseif($rows['auth'] == 'YES' and $rows['location'] == $loc){ 
$bgc = "wait" ;  


 

what works

if    ($rows['auth'] == 'YES' and $rows['location'] == 'SERVER'){ 
$bgc = "pass" ; } 

elseif($rows['auth'] == 'YES' and $rows['location'] == 'HDD'){ 
$bgc = "wait" ;  

}elseif($rows['auth'] == 'YES' and $rows['location'] == 'APRIL 2011'){ 
$bgc = "wait" ;  

}elseif($rows['auth'] == 'YES' and $rows['location'] == 'WHITE VISTA'){ 
$bgc = "wait" ;  

}elseif($rows['auth'] == 'YES' and $rows['location'] == 'NEW 1.5 TB'){ 
$bgc = "wait" ;  

}elseif($rows['auth'] == 'YES' and $rows['location'] == 'UNVALIDATED'){ 
$bgc = "wait" ;  

}else{
$bgc = "fail"; }

 

thx

Link to comment
https://forums.phpfreaks.com/topic/235991-elseif/
Share on other sites

thx gizmola

 

for any1 intrested i solved it with

 

$hddloc = array("HDD","APRIL 2011" ,"WHITE VISTA" ,"NEW 1.5 TB" ,"UNVALIDATED");

if    ($rows['auth'] == 'YES' and $rows['location'] == 'SERVER'){ 
$bgc = "pass" ; } 

elseif ($rows['auth'] == 'YES' and in_array($rows['location'], $hddloc)) {
$bgc = "wait" ; 

}else{
$bgc = "fail"; }

Link to comment
https://forums.phpfreaks.com/topic/235991-elseif/#findComment-1213255
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.