Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If-elseif-elseif-else逻辑与html&;php代码elseif条件未执行_Php_Html_Cakephp 1.3 - Fatal编程技术网

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'])你看到了什么?就像上面说的:在这之前,你可以用一点代码来设置按钮文本,你不会只有一组按钮,比如