-1

if语句会混合固定作业和不应返回的其他结果。无法弄清楚为什么这么简单的事情不起作用。

if($item["total_spent"] >= '1000' 
    && ($item["country"] == 'United States' || $item["country"] == 'Canada')
    && ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] = 'More than 6 months') 
    && ($item["job_engagement"] == 'Full-time - 30+ hrs/week' || $item["job_engagement"] = 'Part-time - 10-30 hrs/week') 
    && ($item["job_type"] == 'Hourly') )
4

3 回答 3

1

也许,你的意思是这样的:

if($item["total_spent"] >= '1000' 
        && ($item["country"] == 'United States' || $item["country"] == 'Canada')
        && ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] == 'More than 6 months') 
        && ($item["job_engagement"] == 'Full-time - 30+ hrs/week' || $item["job_engagement"] == 'Part-time - 10-30 hrs/week') 
        && ($item["job_type"] == 'Hourly') )

=注意在某些 where 子句中使用 single

于 2012-11-23T02:15:15.410 回答
1

看起来您在代码中有几个意外分配,以下是否有效?

<?php
if($item["total_spent"] >= '1000' 
            && ($item["country"] == 'United States' || $item["country"] == 'Canada')
            && ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] == 'More than 6 months') 
            && ($item["job_engagement"] == 'Full-time - 30+ hrs/week' || $item["job_engagement"] == 'Part-time - 10-30 hrs/week') 
            && ($item["job_type"] == 'Hourly')
) {
    // ...
}
于 2012-11-23T02:16:54.720 回答
1
$item["job_engagement"] = 'Part-time - 10-30 hrs/week'
$item["job_duration"] = 'More than 6 months'

这些行的编写就像您在分配值一样,它们应该是:

$item["job_engagement"] == 'Part-time - 10-30 hrs/week'
$item["job_duration"] == 'More than 6 months'
于 2012-11-23T02:17:50.540 回答