dongqie4402 2015-11-08 19:21
浏览 28
已采纳

如何轻松地在MySQL中存储状态? [关闭]

I don't know PHP or SQL at all, only client-side scripting (HTML/JS). Basically, I would like to create a list with a few items which each can be added or removed by me. The functionality is so that if any of the items (.item) is clicked (well, if .item.mark gets clicked) a prompt shows "Would you like to mark this?" and if clicked yes, it gets stored in the SQL as 'marked', which results in a change of appearance. However if item.remove gets clicked, the mark gets removed.

"Bonus points": I want a prompt when the site is opened asking your name. The ID (#) gets hidden that equals the entered name


The thing that I would lik to create is an overview of each of my family members wishlist for Christmas. By marking each item it's shown that someone is buying that present.


Apologies for asking almost a complete tutorial to create this, as it is actually not intended to do so.

  • 写回答

1条回答 默认 最新

  • doutan8601 2015-11-08 19:50
    关注

    Since you indicated that you do not know PHP or MySQL at all, then I will address your question by providing you with a general answer as to how this can be achieved. After that, I will provide you with my opinion why this is generally a bad idea.

    1: Register event handlers in JavaScript/jQuery for the classes you want to bind with, i.e. .item, .item.mark

    2: Handle the 'click' by prompting the user to choose (yes/no) for the target to be marked. Target here means the item being clicked.

    3: Get the user response (yes/no), and preferably format it as JSON format (JavaScript Object Notation).

    4: Send the JSON data to the server (this assumes that you have your server configured, and that you have CGI enabled or have PHP or any other server side scripting language setup to handle the request).

    5: In the server, once the JSON data is received, the scripting language, i.e. PHP, etc.,let us say it's PHP for now, it will open and establish a database connection (this assumes that you have MySQL configured and setup correctly), at which point, PHP will parse the JSON data and input the data into the database.

    So, this is generally how it is done, although there are variety of ways to implement it, for example, using AJAX and such, but it follows this general pattern. Since you indicated that you do not know PHP and MySQL, and assuming that you do not know any other scripting language, it would be practical if you were to hire a web-developer to assist you with this, as this is a rather specific set of requirements that involve many other components that each require a level of expertise in.

    Now, this solution does not take into consideration the detrimental security implications, that is an entirely different discussion that goes beyond the scope of this thread.

    Would I implement it this way? Absolutely not. It would be helpful had you provided some technical background as to the nature of your application, i.e. server environment, do you know JavaScript/jQuery? Do you know any other scripting language? etc.

    Hope this provided you with an insight that although conceptually simple, it does involve many components and consideration, including security implications and such.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多