I'm running wordpress and this is to search. Basically, I'm going to set the post type based on what checkboxes are selected (if they're checked, they pass a value of 1).
When searching my URL includes job=1&opportunity=1&resource=1
, and I've tried the values both with and without quotes, it will not output HELLO
at all.
$job = wp_specialchars(stripslashes($_GET["job"]), 1);
$opportunity = wp_specialchars(stripslashes($_GET["opportunity"]), 1);
$resource = wp_specialchars(stripslashes($_GET["resource"]), 1);
if(($job == '1') && ($opportunity == '1') && (resource == '1')){
echo 'HELLO';
}elseif($job == '1' && $opportunity == '1'){
}elseif($job == '1' && resource == '1'){
}elseif($opportunity == '1' && resource == '1'){
}elseif($job == '1'){
}elseif开发者_运维知识库($opportunity == '1'){
}elseif($resource == '1'){
}
Also, if anyone can make this a shorter/more semantic if statement, by all means, go for it.
If above code is pasted then look at the following:
if(($job == '1') && ($opportunity == '1') && (resource == '1')){
resource should be $resource
}elseif($opportunity == '1' && resource == '1'){
resource should be $resource
You might want to try these and execute again (although errors might be expected with the above code).
You seem to have a typo:
if(($job == '1') && ($opportunity == '1') && (resource == '1')){
$
is missing for resource
.
Make sure you have error reporting turned on (error_reporting(E_ALL);
- this particular issue will throw a E_NOTICE
level warning.
if(($job == '1') && ($opportunity == '1') && (resource == '1')){
^--missing a $ here
}elseif($job == '1' && resource == '1'){
^--- and here
}elseif($opportunity == '1' && resource == '1'){
^---and here too
精彩评论