Jump to content

if false go to next if


jesushax

Recommended Posts

hi below is my code qwhich will hopefully explain the problem a little clearer

 

if you look at the none set error statments, im checking for words in the field

then if certain words are met do something, now if there not met its set to do nothing, but i want it to be set to the last else in the statement that its within, without having to repeat this bit

 

if ($error["City"] =="1") {....

 

at the end of everyone of those

 

anyone understand?

 

 

if ($error["Cons"] !="1" && $error["City"] !="1") {
header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error1");
} elseif (empty($error["Ref"])) {
header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error2");
} elseif ($error["City"] =="1") {
if ($error["CityCat"] =="None Set") {
header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error3");
}
} elseif ($error["Cons"] =="1") {
if ($error["ConsCat"] =="None Set") {
header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error4");
}
} else {
if ($error["City"] =="1") {
header("Location: /admin/vacancies/edit_vac_list.php?CAT=$CityCat");	}
elseif ($error["Cons"] =="1") {
header("Location: /admin/vacancies/edit_vac_list.php?CAT=$ConsCat");	}
}

Link to comment
https://forums.phpfreaks.com/topic/128217-if-false-go-to-next-if/
Share on other sites

That is one big bowl of spaghetti.  By

'without having to repeat if($error["city"]=="1")'

do you mean you need to check if $error['city']==1 on every if statement?  Or is it different on each one?  Break your question down into sentences maybe, it's pretty unclear.

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.