使用PHP和Javascript将多媒体消息插入MySQL数据库

时间:2022-01-22 07:34:18

I was working on a website for which I was designing the conversation system (Post, comment, like, etc.) like what all social networking sites have.

我正在建立一个网站,我正在设计会话系统(发布,评论等等),就像所有社交网站一样。

I am trying to provide option for inserting smileys along with the normal text content in a textarea.

我试图提供在文本区域中插入表情符号和普通文本内容的选项。

My Questions

  1. How do I add images like smileys in a textarea (which accepts only text by default) as and when user selects one from the list or puts in the symbol
  2. 当用户从列表中选择一个或放入符号时,如何在textarea(默认情况下只接受文本)中添加像smileys这样的图像

  3. Once I have the textarea with smileys and normal text, what is the best way to store it in the MySQL database
  4. 一旦我有带有表情符号和普通文本的textarea,将它存储在MySQL数据库中的最佳方法是什么

  5. When displaying the message with smileys, what is the best way to parse the message from the database
  6. 使用smileys显示消息时,从数据库解析消息的最佳方法是什么

NOTE

I am aware of developing a conversation system with just plain text and files. I am just not sure how to add,store,display smileys.

我知道用纯文本和文件开发会话系统。我只是不确定如何添加,存储,显示表情符号。

I am already aware of plugins like Tinymce: http://www.tinymce.com/tryit/basic.php

我已经知道像Tinymce这样的插件:http://www.tinymce.com/tryit/basic.php

But I want to know how to make my own.

但我想知道如何制作自己的。

2 个解决方案

#1


1  

textarea can't be used to display images,use a contenteditable div instead.

textarea不能用于显示图像,而是使用contenteditable div。

As for the backend,store data in the database regularly (ex: Store :) directly) and maintain a common table/array where you replace these text with the image/smiley each time you display the data.

至于后端,定期将数据存储在数据库中(例如:直接存储:),并维护一个公共表/数组,每次显示数据时都用图像/笑脸替换这些文本。

#2


1  

Wouldn't having some kind of inline notation help here? You could have something like [::smiley-XXX::] where that represents a particular smile. So long as it's something users are unlikely to type by accident it'll be fine.

在这里不会有某种内联符号帮助?你可以拥有类似[:: smiley-XXX ::]的东西,其中代表一个特别的微笑。只要这是用户不太可能意外输入的东西,那就没关系了。

Then you need a way of converting that from text into HTML, where you inline the appropriate image.

然后,您需要一种将文本转换为HTML的方法,在这里您可以内联相应的图像。

#1


1  

textarea can't be used to display images,use a contenteditable div instead.

textarea不能用于显示图像,而是使用contenteditable div。

As for the backend,store data in the database regularly (ex: Store :) directly) and maintain a common table/array where you replace these text with the image/smiley each time you display the data.

至于后端,定期将数据存储在数据库中(例如:直接存储:),并维护一个公共表/数组,每次显示数据时都用图像/笑脸替换这些文本。

#2


1  

Wouldn't having some kind of inline notation help here? You could have something like [::smiley-XXX::] where that represents a particular smile. So long as it's something users are unlikely to type by accident it'll be fine.

在这里不会有某种内联符号帮助?你可以拥有类似[:: smiley-XXX ::]的东西,其中代表一个特别的微笑。只要这是用户不太可能意外输入的东西,那就没关系了。

Then you need a way of converting that from text into HTML, where you inline the appropriate image.

然后,您需要一种将文本转换为HTML的方法,在这里您可以内联相应的图像。