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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.