Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.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
Php 尝试在if条件下显示背景色_Php_Html_Css - Fatal编程技术网

Php 尝试在if条件下显示背景色

Php 尝试在if条件下显示背景色,php,html,css,Php,Html,Css,如果PHP中满足if条件,我将尝试使用背景色(使用class-badge&badge primary)来显示文本。但似乎有一些语法问题。代码在没有超链接标记的情况下工作 <?php $active_info=$this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->student_session; if (

如果PHP中满足if条件,我将尝试使用背景色(使用class-badge&badge primary)来显示文本。但似乎有一些语法问题。代码在没有超链接标记的情况下工作

 <?php
      $active_info=$this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->student_session;
                if ($active_info['student_session'] == 1)
                 <a class="badge badge-primary" href="javascript:void(0);">echo get_phrase("Active Login"); </a>
                  if ($active_info['student_session'] == 2)
                 echo get_phrase("Inactive Login");
                 ?>

对于您提交的代码部分,正确的语法是:

    <?php
      $active_info=$this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->student_session;
                if ($active_info['student_session'] == 1)

                  echo '<a class="badge badge-primary" href="javascript:void(0);">' . get_phrase("Active Login").'</a>';
if ($active_info['student_session'] == 2)
                 echo get_phrase("Inactive Login");
                 ?>

说明:


要将文本打印到PHP,需要使用echo或其他专用函数。使用“或”来包含字符串并使其可读。

问题在于从PHP脚本呈现html。这应该可以

//your code
if ($active_info['student_session'] == 1){
             echo '<a class="badge badge-primary" href="javascript:void(0);">' . get_phrase("Active Login") . '</a>';
}
//your php code continues
//您的代码
如果($active_info['student_session']==1){
回声';
}
//您的php代码将继续

为了确保能提出好的答案,你能粘贴更多的代码吗?但事实上,你的代码有一个很大的语法问题,经过编辑,问题和代码更加清晰。对于其他人来说,阅读你的问题,最好标记答案是验证你的问题你是生命的救世主,非常感谢你,兄弟……它奏效了。