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.
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.