简体   繁体   English

如何允许客户通过同一网页更新网页上的文本内容

[英]How to allow a client to update the textual content on a webpage through that same webpage

Hi I have been rattling my brain for hours online trying to figure out how to allow my client to edit the textual content on the site I am creating for them all I need is a text area that can be edit directly or a seperate text box that once my client has input their text and clicked submit the textual content above is replaced with the new content. 嗨,我已经花了数小时在网上动了脑筋,试图弄清楚如何让我的客户在为他们创建的网站上编辑文本内容,我所需要的就是一个可以直接编辑的文本区域或一个单独的文本框,一旦我的客户输入了他们的文本并单击提交,上面的文本内容就会被新内容替换。 The content needs to be saved permenatly vistors to the site can see. 内容需要永久保存,以使访问者可以看到该站点。

I am at college so I am still learning and any suggestions would be a great help thank you. 我正在上大学,所以我仍在学习,任何建议都会对您有所帮助。

There are multiple way to achieve what you want. 有多种方法可以实现您想要的。 But since you tagged your question with PHP and database, i will give you an example of how to do it using these. 但是,由于您用PHP和数据库标记了您的问题,因此我将为您提供一个如何使用这些示例的示例。

This is the simplest way to do it, if you want to get something more complex, you should look into getting a framework like symfony or silex. 这是最简单的方法,如果您想要更复杂的东西,则应该考虑使用诸如symfony或silex之类的框架。

In order to display the text to the user, you need to : 为了向用户显示文本,您需要:

  1. Connect to the mysql database 连接到mysql数据库
  2. Fetch the message form the database table and return it in a variable 从数据库表中获取消息并以变量形式返回

To update the text. 更新文本。

  1. Return the text from textarea to a PHP page. 将文本从textarea返回到PHP页面。
  2. Connect the same way to the database. 以相同的方式连接到数据库。
  3. Run an UPDATE SQL statement to change the value. 运行UPDATE SQL语句以更改值。

All these can be made in a single page, Look in these resources to make it: 所有这些都可以在一个页面中完成,请查看以下资源以使其成为:

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

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