允许用户通过单击 Word 来更改文本
我正在尝试使用 PHP 来显示一小段文本,其中每个单词都可以由用户单击和更改。
例如:“敏捷的棕色狐狸跳过了懒狗。”用户可以通过弹出窗口形式或出现的菜单单击“跳跃”并将其更改为“行走”。
我想使用数据库来跟踪更改,并可能以某种方式显示过去迭代中的文本。我是个新手,所以不要害怕具体。
谢谢!
I'm trying to use PHP to display a short paragraph of text in which each word can be potentially clicked and changed by the user.
For example: "The quick brown fox jumps over the lazy dog." The user could click on "jumps" and change it to "walks", either via a popup window form or a menu that appears.
I'd like to use a database to keep track of the changes and maybe display the text in its past iterations in some way, too. I am kind of a novice, so don't be afraid to be specific.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,支持 HTML5 的浏览器可以通过正确使用
contenteditable
属性来执行此操作。如果您想向后兼容,则需要搜索某种内联编辑 (jQuery) 插件。顺便说一句,这首先与 PHP、数据库无关,因为用户交互发生在客户端,使用 HTML5 或 JavaScript 作为后备。当然,编辑完成后,您可能希望借助 PHP 将提交的数据存储在数据库中。
HTML5-capable browsers can do this by default with proper use of
contenteditable
attribute. If you'd like to be backwards-compatible, you'll need to search for some kind of inline-editing (jQuery) plugin.Btw at first this has nothing to do with PHP, databases because the user interaction happens at the client side natively with HTML5 or with JavaScript as a fallback. Of course, when editing done, you may want to store the submitted data in a database with the help of PHP.