【问题标题】:How can I truncate the multiline text from the database? (html/css/php)如何从数据库中截断多行文本? (html/css/php)
【发布时间】:2021-02-01 14:28:51
【问题描述】:

如何截断从 MySQL 数据库中获取的数据?

我的html代码:

<div class="content">
    <h3 class="title"><?php echo $title; ?></h3>
    <p class="main" id="main"><?php echo $content; ?></p>
    <a href="#"><i class="fa fa-arrow-right"></i> Artikel lesen</a>
</div>

【问题讨论】:

  • 发布完整代码。 $title$content 是什么?

标签: javascript php html css sql


【解决方案1】:

如果要截断列的值,可以直接使用leftright 函数来实现。您需要分别从左侧或右侧传递要获取的字符数量

例如:left()

select left('left function',4) as content;

output: left

例如:right()

select right('left function', 4) as content;

output: tion

如果content 是您的专栏,那么您可以使用以下 sn-p:

select left(content,10) as content from <YourTableName>;

【讨论】:

    猜你喜欢
    • 2018-02-07
    • 2013-07-08
    • 1970-01-01
    • 2012-07-23
    • 1970-01-01
    • 2022-10-02
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    相关资源
    最近更新 更多