简体   繁体   English

在HTML网页中没有换行符的SQL表显示

[英]SQL table display without linebreaks in HTML webpage

I want to display a paragraph of text (stored in a SQL table) in html. 我想在html中显示一段文本(存储在SQL表中)。 The problem I have is, all the linebreaks gets removed when it is displayed on the webpage. 我的问题是,当所有换行符显示在网页上时,都将其删除。

The text would be like: 文本如下:
Day 1, 第一天
This is the first day. 这是第一天。
The day is done at last. 这一天终于完成了。

And it would display like: 它将显示为:
Day 1, This is the first day. 第一天,这是第一天。 The day is done at last. 这一天终于完成了。

  • I have originally used 'TEXT', but changed to 'VARCHAR'. 我最初使用的是“ TEXT”,但后来更改为“ VARCHAR”。
  • The text has been manually inserted into my phpAdmin in the cpanel 文本已手动插入cpanel的phpAdmin中

The code is 该代码是

    $result = mysqli_query($conn, "SELECT tablea.id, tableb.id, tablea.name, tablea.surn, tableb.messg, tableb.tdate, tableb.person, FROM tablea INNER JOIN msgs ON tablea.id=tableb.id WHERE id=$id ORDER BY tdate ASC")

or die(mysqli_error($conn));

while($row = mysqli_fetch_array( $result )) {

                ?>

            <div>

                <div>

                    <p>
                        <?php echo strtoupper($row["person"]); ?>
                    </p>

                    <p>
                        <?php echo $row["messg"]; ?>
                    </p>

                    <p>
                        <?php echo $row["tdate"]; ?>
                    </p>

                </div>

            </div>

使用nl2br()函数将换行符转换为HTML换行符(<br nl2br()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM