简体   繁体   English

在数据库中插入所见即所得的编辑器文本

[英]Insert WYSIWYG editor text in the database

I'm a beginner in PHP, I want to make a page containing WYSIWYG editor and the text tiped in the editor will be displayed in another page. 我是PHP的初学者,我想制作一个包含WYSIWYG编辑器的页面,编辑器中提示的文本将显示在另一页面中。 The question is : how to insert the text with its attributes (bold-italic-image...) in the database to show it in the other page? 问题是:如何在数据库中插入带有属性(粗斜体图像...)的文本以在另一页中显示它? Just like the text editor that we use here on stackoverflow to post questions. 就像我们在stackoverflow上用来发布问题的文本编辑器一样。

Create a form. 创建一个表格。 Put a textarea in it. 在其中放置一个textarea。 Then use one of the WYSIWYG scripts to turn the textarea into an editor. 然后使用所见即所得脚本之一将文本区域转换为编辑器。 When you submit the form, it will send the html code of the WYSIWYG. 提交表单时,它将发送所见即所得的html代码。

WYSIWYG Editors actually build on top of basic HTML Editing functionality that the browsers already have built in. 所见即所得的编辑器实际上是在浏览器已经内置的基本HTML编辑功能的基础上构建的。

to create a WYSIWYG editor you need to use javascript 要创建一个所见即所得的编辑器,您需要使用javascript

Read More Here 在这里阅读更多

JQuery Based Text Editors 基于JQuery的文本编辑器

for storing the data you can simply use html tags 用于存储数据,您可以简单地使用html标签

ie.. 即..

the data look something like this 数据看起来像这样

<P>This is a test</P> <h1>for a question</h1>  

and you can retrieve the data using php echo or print 您可以使用php echo或print检索数据

<?php print "<P>This is a test</P> <h1>for a question</h1> " ?>

You can set the datatype to TEXT for your textarea field. 您可以将textarea字段的数据类型设置为TEXT。 And use a form like this. 并使用这样的形式。

<form action='' method='POST'>
 <textarea class="myEditor" name="description"></textarea>
 <input type='submit' value='Submit'>
</form>

<?php
 if(isset($_POST) !empty($_POST)){
 //Place your insert query here
}
?>

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

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