Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.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 $output内的IF/ELSEIF语句_Php - Fatal编程技术网

Php $output内的IF/ELSEIF语句

Php $output内的IF/ELSEIF语句,php,Php,有人能解释一下如何在$output中添加if/elseif语句吗 谢谢大家! 代码如下: $output .= " <tr> <td class='signal-list'><a href data-toggle='modal' data-target='#showSignal$id'>$id</a></td>

有人能解释一下如何在$output中添加if/elseif语句吗

谢谢大家!

代码如下:

        $output .= "  
                 <tr>  
                     <td class='signal-list'><a href data-toggle='modal' data-target='#showSignal$id'>$id</a></td>
                      <td class='signal-list'>$date_added</td>
                      <td class='signal-list'>$pr</td>
                      <td>$ac</td>
                      <td class='signal-list'>$entr</td>
                      <td>$dir</td>
                      <td>$clo</td>
                      <td>$p_l</td>
                 </tr>  
            ";  
       }  
       $output .= '</table>';  
  }  
  echo $output;  
$output.=”
$date_已添加
$pr
$ac
$entr
$dir
$clo
$p_l
";  
}  
$output.='';
}  
echo$输出;
我想在$output中添加下面的代码

  if($status == 'Profit') {

  echo "<td class='signal-list'><p class='label label-success'>PROFIT</p></td>";

    } elseif($status == 'Loss') {

  echo "<td class='signal-list'><p class='label label-danger'>&nbsp; LOSS &nbsp;</p></td>";

    } else {

 echo "<td class='signal-list'><p class='label label-primary'>&nbsp; LIVE &nbsp;</p></td>";

   }   
if($status=='Profit'){
echo“

利润

”; }elseif($status=='Loss'){ 回声“

丢失”

; }否则{ echo“

LIVE

”; }
$output.=”
$date_已添加
$pr
$ac
$entr
$dir
$clo
$p_l
";
如果($status==‘利润’){
$output.=“

利润

”; } elseif($status=='Loss'){ $output.=“

损失

”; }否则{ $output.=“

LIVE

”; } $output.=” "; $output.=''; echo$输出;
$output.=”
$date_已添加
$pr
$ac
$entr
$dir
$clo
$p_l
";
如果($status==‘利润’){
$output.=“

利润

”; } elseif($status=='Loss'){ $output.=“

损失

”; }否则{ $output.=“

LIVE

”; } $output.=” "; $output.=''; echo$输出;
这取决于您希望附加单元格位于现有单元格之前还是之后,但您需要做的只是将
置于
$output
添加之外,然后将
echo
更改为使用
=
附加到
$output
变量

下面是一个示例,展示了随后添加的内容,但是如果希望事先添加,您可以轻松地交换
现有单元格
新单元格
;结构仍然是正确的

<?php

// Start the table and table row - note that you do not use `.=` here
$output = '<table><tr>';

// Existing cells
$output .= "  
    <td class='signal-list'><a href data-toggle='modal' data-target='#showSignal$id'>$id</a></td>
    <td class='signal-list'>$date_added</td>
    <td class='signal-list'>$pr</td>
    <td>$ac</td>
    <td class='signal-list'>$entr</td>
    <td>$dir</td>
    <td>$clo</td>
    <td>$p_l</td>
    ";

// New cells
if($status == 'Profit') {
  $output .= "<td class='signal-list'><p class='label label-success'>PROFIT</p></td>";
} elseif($status == 'Loss') {
  $output .= "<td class='signal-list'><p class='label label-danger'>&nbsp; LOSS &nbsp;</p></td>";
} else {
  $output .= "<td class='signal-list'><p class='label label-primary'>&nbsp; LIVE &nbsp;</p></td>";
}

// End the table row and table itself
$output .= '</tr></table>';  

echo $output;

这取决于您希望附加单元格位于现有单元格之前还是之后,但您需要做的只是将
置于添加的
$output
之外,然后将
echo
更改为使用
=
附加到
$output
变量

下面是一个示例,展示了随后添加的内容,但是如果希望事先添加,您可以轻松地交换
现有单元格
新单元格
;结构仍然是正确的

<?php

// Start the table and table row - note that you do not use `.=` here
$output = '<table><tr>';

// Existing cells
$output .= "  
    <td class='signal-list'><a href data-toggle='modal' data-target='#showSignal$id'>$id</a></td>
    <td class='signal-list'>$date_added</td>
    <td class='signal-list'>$pr</td>
    <td>$ac</td>
    <td class='signal-list'>$entr</td>
    <td>$dir</td>
    <td>$clo</td>
    <td>$p_l</td>
    ";

// New cells
if($status == 'Profit') {
  $output .= "<td class='signal-list'><p class='label label-success'>PROFIT</p></td>";
} elseif($status == 'Loss') {
  $output .= "<td class='signal-list'><p class='label label-danger'>&nbsp; LOSS &nbsp;</p></td>";
} else {
  $output .= "<td class='signal-list'><p class='label label-primary'>&nbsp; LIVE &nbsp;</p></td>";
}

// End the table row and table itself
$output .= '</tr></table>';  

echo $output;

也许我不够清楚。。我想在当前$output not new和HTML表中添加此代码。对不起,using.=您使用的字符串与$output=$output相同,不是新字符串。“什么”也许我不够清楚。。我想在当前$output not new和HTML表中添加此代码。对不起,using.=您使用的字符串与$output=$output相同,不是新字符串。“什么”