【问题标题】:Putting two conditional results in a table将两个条件结果放入表中
【发布时间】:2018-05-25 00:36:24
【问题描述】:

我正在尝试将两个条件 if 结果语句放在一个表中,但无法获得结果。

所以如果表单输入为空,则不显示结果。

为了节省空间,我想将结果放在两列或三列的表格中。

       if( ! empty( $lect ) )
           $result .= '<p>'. __('<table class="custom-data"><span id="si" >Name:</span> ').'<span id="si1" >'.$lect.'</span></table></p>';
    if( ! empty( $lect1 ) )
           $result .= '<p>'. __('<table class="custom-data"><span id="si">Product :</span> ').'<br><span id="si1" >'.$lect1.'</span></table></p>';

当前输出:
预期输出:

【问题讨论】:

  • 结果为附图表格
  • 你能把$select$select1的代码贴出来
  • 抱歉编辑它是 lect lect1 需要显示在两列表格中...请忽略我的英语差
  • 那么请在$lect$lect1 设置的位置发帖。显然它们没有被设置或被设置为 null 或 0
  • @WillParky93 这些代码已经过测试并且可以工作,但我需要将它们放在表格中,css 可能有点偏离

标签: php html css wordpress html-table


【解决方案1】:

请参阅下文以分隔成单独的列:

$result .= '<table class="custom-data"><tr>';
if( ! empty( $lect ) )
   $result .= '<td><p>'. __('<span id="si" >Name:</span> ').'<span id="si1" >'.$lect.'</span></p></td>';
if( ! empty( $lect1 ) )
   $result .= '<td><p>'. __('<span id="si">Product :</span> ').'<br><span id="si1" >'.$lect1.'</span></p></td>';
$result .= '</tr></table>';

那我猜你正在返回$result。这把结果放在一行和条件列中。

【讨论】:

  • 我在您的代码中没有看到 div。也许发布你的整个代码。
  • 它破坏了我的网站
  • 您需要弄清楚发生了什么问题。也许发布您的整个代码和错误消息。
  • 很抱歉,因为非常紧急的工作,你在吗?我可以提供登录凭据
  • 在这里给我发电子邮件 web-designer.ninja
猜你喜欢
  • 1970-01-01
  • 2014-05-16
  • 2022-11-16
  • 1970-01-01
  • 1970-01-01
  • 2023-02-08
  • 1970-01-01
  • 2022-11-18
  • 1970-01-01
相关资源
最近更新 更多