我正在使用 sqlite 数据库在 php 中开发应用程序。我已经为textarea整合了 tinymce 4.1.9 。当我在数据库中保存数据时,正确的html脚本被保存,但是在报告中显示来自数据库的数据时,所有html标签都没有反映出来。例如H1或列表或粗体不显示其效果。甚至标签也会保存在数据库中。 脚本如下:
<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'];}
?>
请建议如何在报告中显示格式化数据?
答案 0 :(得分:1)
尝试使用PHP htmlentities()函数将字符转换为html格式。让我知道结果。