【问题标题】:Displaying the text in the multiple lines when retrieving from database从数据库中检索时显示多行文本
【发布时间】:2011-07-21 05:41:08
【问题描述】:

嗨 我有一个表,其中我的行包含我从数据库中检索的文本。但是我的行宽度很小,我检索的数据很大。并且文本超出了我的行的宽度,所以我想破坏数据我检索到表格行内的多行。我该怎么做。 我的代码在这里:

$list = $mfidao1->fetchMfi($_GET['id']); 
//print_r($list);
//die;
if(!empty($list))
{
foreach($list as $menu)
{
?>

<tr style="border:none; background-color:#FBFBFB;" >
<td class="topv">Social Mission</td>
<td class="topm" ><div class="txt"><?php echo $menu->mfi_1_a;?></div></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Address</td>
<td class="topm"><?php echo $menu->mfi_ii_c;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Phone</td>
<td class="topm"><?php echo $menu->mfi_ii_e;?></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Email</td>
<td class="topm"><?php echo $menu->mfi_ii_d;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Year Established</td>
<td class="topm"><?php echo $menu->mfi_i_c;?></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Current Legal Status</td>
<td class="topm"><?php echo $menu->mfi_i_d;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Respondent</td>
<td class="topm"><?php echo $menu->mfi_ii_a;?></td>
</tr>
<?php
}
}
?>
</table>

【问题讨论】:

  • HTML 会忽略回车,直到您采取措施阻止它。

标签: php html css


【解决方案1】:

设置&lt;td&gt;的宽度。我认为这是最好的方法,而不是 word_wrap()。

【讨论】:

    【解决方案2】:

    在表格的 css 中,使用“table-layout:fixed” - 这会根据您想要的方式固定 td 元素的宽度。 " word-wrap: break-word; " - 这会破坏其中的文本,使其不会超出框的边界。

    【讨论】:

      【解决方案3】:

      您需要将文本包装在 td 标签中。 Here is a link to a similar question

      【讨论】:

        【解决方案4】:

        您可以使用函数wordwrap()

        它使用字符串分隔符将字符串包装成给定数量的字符。

        【讨论】:

          【解决方案5】:

          你可以使用php函数

          php wordwrap

          或使用 css 设置 td 样式,使其使用自动换行属性

          css wordwrap

          【讨论】:

            【解决方案6】:

            不确定这是否是您想要的,但听起来您可以使用chunk_split()

            【讨论】:

              猜你喜欢
              • 2014-01-10
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2018-10-11
              • 2013-03-23
              • 1970-01-01
              • 2016-02-09
              • 1970-01-01
              相关资源
              最近更新 更多