PHP:显示sqlite数据库中的html格式数据,使用tinymce保存

PHP :Displaying html formatted data from sqlite database, saved using tinymce

本文关键字:数据 格式 使用 保存 tinymce html 显示 sqlite 数据库 PHP      更新时间:2023-09-26

我正在php中使用sqlite数据库开发应用程序。我已经为文本区域集成了tinymce 4.1.9。当我在数据库中保存数据时,会保存正确的html脚本,但当在报表上显示数据库中的数据时,所有html标记都不会反映出来。例如H1、list或bold不显示其效果。甚至标签也保存在数据库中。脚本如下:

<script language="javascript" type="text/javascript" src="tinymce/js/tinymce/tinymce.min.js"></script>

<script language="javascript" type="text/javascript">
    tinymce.init({
            selector: "textarea",
            theme: "modern",
            plugins: [
            "advlist autolink lists link image charmap print preview hr anchor pagebreak",
            "searchreplace wordcount visualblocks visualchars code fullscreen",
            "insertdatetime media nonbreaking save table contextmenu directionality",
            "emoticons template paste textcolor colorpicker textpattern"
        ],
            toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
            toolbar2: "print preview media | forecolor backcolor emoticons",
            image_advtab: true,
            templates: [
            {title: 'Test template 1', content: 'Test 1'},
            {title: 'Test template 2', content: 'Test 2'}
        ]
    });
</script>

Html:

<textarea name="txtAboutComp" class="form-control" rows="5" ></textarea>

在报告上显示数据:

  <?php
                        try 
                        {
                            $sqlite = new PDO('sqlite:DigitalStorageBox.sqlite');
                        }
                        catch (PDOException $e) 
                        {
                            echo 'Connection failed: ' . $e->getMessage();
                        }
                        $statement = $sqlite->prepare('SELECT distinct ID, Name, LogoPath,CompanyName,AboutCompany from  Company ');    
                        try 
                        {
                            $statement->execute();
                        }
                        catch (PDOException $e) 
                        {
                            echo "Statement failed: " . $e->getMessage();
                            return false;
                        } 
                        $result = $statement->fetchAll();
                        $cnt=0;
                        foreach ($result as $row) 
                        { echo $row['AboutCompany'];}
                ?>

请建议如何在报告中显示格式化数据?

尝试使用PHP htmlenties()函数将字符转换为html格式。让我知道结果。