If-elseif-elseif-else逻辑与html&;php代码elseif条件未执行
我有一些情况的代码要首先检查,然后代码应该根据它执行。我的代码If-elseif-elseif-else逻辑与html&;php代码elseif条件未执行,php,html,cakephp-1.3,Php,Html,Cakephp 1.3,我有一些情况的代码要首先检查,然后代码应该根据它执行。我的代码 <?php if($this->Session->read('Auth.User.id')==''){ ?> <input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:register_popup();"&
<?php if($this->Session->read('Auth.User.id')==''){ ?>
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:register_popup();">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:submitPlan(2);">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:submitPlan(3);">
<?php } elseif($this->Session->read('Auth.User.id')!='' && $this->Session->read('Auth.User.role_id')=='3' && isset($this->data['User']['plan_type']) && $this->data['User']['plan_type']=='A'){ ?>
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Your plan" onclick="javascript:register_popup();">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:submitPlan(2);">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:submitPlan(3);">
<?php } elseif($this->Session->read('Auth.User.id')!='' && $this->Session->read('Auth.User.role_id')=='3' && $this->data['User']['plan_type']=='B'){ ?>
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:register_popup();">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Your plan " onclick="javascript:submitPlan(2);">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:submitPlan(3);">
<?php } else{?>
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:register_popup();">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Start now" onclick="javascript:submitPlan(2);">
<input class="profilebtn" type="button" style="width:100px !important; margin-top: 1px;" value="Your plan" onclick="javascript:submitPlan(3);">
<?php } ?>
所以我有3个按钮在每个条件下,所以根据用户已经计划,我想改变按钮值从现在开始到您的计划和休息2按钮应该有现在开始选项。因此,在这段代码中,如果条件不匹配,那么将直接执行of else,而不是首先检查else if部分。仅当值满足所有条件时,ELSEIF才会运行。如果它们未执行,则至少有一个条件未满足 例如,您是否可以确定此处的变量:
$this->Session->read('Auth.User.id')!=''
&& $this->Session->read('Auth.User.role_id')=='3'
&& $this->data['User']['plan_type']=='B')
一切都如你所愿吗?试着用(真)作为条件再做一个elseif。因此,您可以检查elseif是否能够自行工作。 如果它跳进去,你的两种情况都有问题 手动检查变量,如
var_dump($this->Session->read('Auth.User.role_id')=='3');
并检查输出是否符合您在条件下的计划
var_dump($this->data['User']['plan_type'])代码>你看到了什么?就像上面说的:在这之前,你可以用一点代码来设置按钮文本,你不会只有一组按钮,比如