2010-04-24 74 views
1

如何获得$ schedule = true`和$ schedule2 = true的工作?简单的PHP语句,我无法让它工作!

我知道这很简单,我可以忽略一些简单的事情!

这里是全码:(!它看起来在PHP日期,并告诉它什么时候在我们的新闻网站到期)

我基本上要安排和了schedule2工作

$where = array(); 
$where = run_filters('also-allow', $where); 

if ($allow_full_story or $allow_add_comment) { 
    $post = 'full'; 

    if ($title){ 
     $where[] = "url = $title"; 
    } elseif ($time){ 
     $where[] = "date = $time"; 
    } elseif ($id){ 
     $where[] = "id = $id"; 
    } 
} else { 
    $post = 'short'; 

    if (!$is_logged_in or $is_logged_in and $member['level'] == 4) { 
     $where[] = 'hidden = 0'; 
     $where[] = 'and'; 
    } 

    if ($user or $author) { 
     $where[] = 'author = '.($author ? $author : $user); 
     $where[] = 'and'; 
    } 

    if ($year and !$month) { 
     $where[] = 'date > '[email protected](0, 0, 0, 1, 1, $year); 
     $where[] = 'and'; 
     $where[] = 'date < '[email protected](23, 59, 59, ($year == date("Y") ? date("n") : 12), ($year == date("Y") ? date("d") : 31), $year); 
    } elseif ($year and $month and !$day) { 
     $where[] = 'date > '[email protected](0, 0, 0, $month, 1, $year); 
     $where[] = 'and'; 
     $where[] = 'date < '[email protected](23, 59, 59, $month, (($year == date("Y") and $month >= date("n")) ? date("d") : 31), $year); 
    } elseif ($year and $month and $day) { 
     if($year == date("Y") and $month >= date("n") and $day >= date("d")) { 
      $where[] = 'hidden = 2'; 
     } 
     else { 
      $where[] = 'date > '[email protected](0, 0, 0, $month, $day, $year); 
      $where[] = 'and'; 
      $where[] = 'date < '[email protected](23, 59, 59, $month, $day, $year); 
     } 
    } 
    else { 
    if ($schedule) { 
     $where[] = 'date > '.(time() + $config_date_adjust * 60 - 432000); 
    } 
    else { 
     $where[] = 'date < '.(time() + $config_date_adjust * 60); 
    } 
    $schedule = false; 
} 
else { 
    if ($schedule2) { 
     $where[] = 'date > '.(time() + $config_date_adjust * 60 - 86400); 
    } 
    else { 
     $where[] = 'date < '.(time() + $config_date_adjust * 60); 
    } 
    $schedule2 = false; 
} 
+1

什么?你能解释一下你期望这段代码做什么,它实际上在做什么? – 2010-04-24 00:53:28

+0

@Tyler:看起来他正在创建一个sql语句 – SeanJA 2010-04-24 00:56:27

+0

@SeanJA是的,但我的意思是关于他想用'$ schedule'来做什么,以及他无法完成的功能。 – 2010-04-24 01:00:53

回答

7

你可以没有连续的2 else s。 也许elseif,但没有人知道你的逻辑。

+0

他每个if只有1个'else'。如果你仔细观察,你会看到。 (当然,代码的格式很残忍) – 2010-04-24 01:01:01

+3

不然,它还有其他的东西:'else {... $ schedule = false;} else {if(...'我在Netbeans中检查过它。 – SeanJA 2010-04-24 01:14:07

0

您使用太多其他的。试着简化你的代码,使用CASE。