I will ask a theoretical question: It is necessary to deal with the correct operation of the mysql database with PHP, I know the basics - I can save, display, etc., but there are some nuances:

  1. There are related tables - what are the ways to select data from a linked table? THOSE. What is the point of relationships between tables, how is it used in PHP?
  2. I can not understand how the following should work properly: There is, for example, an Input to which a value should fall from the base, then there is a button by pressing which data from the input should be recorded in the database. Here there are two options: The first request is made to the database - it turns out that there is no data in the database that should get into the input, so it remains empty, then it is changed by pens and when you click on the save button, you must send a request to add a new record (i.e. . Insert into table123 ....). The second is when the data in the database is already there and they are loaded into input, then the input is changed again with pens and the query should already be not for adding a new record and updating the old one (Ie Update ....). How generally to organize such when on the form the whole heap of such inputs?
  • Links in the database to php have nothing to do. They are needed to ensure that errors in the code in php would not lead the database to an inconsistent state. For example, when in the property table of an object there is data for an object ID = 99, and in the table of objects such an object simply does not exist. - Mike
  • And regardless of the number of input'ov usually the whole page works entirely with 1-2 tables. And often - with a single record of the main table and, possibly, with several subordinates to it. So you immediately took to the page or record in the html table when you formed html, you took this record from the database or it is new, fix this fact in some hidden field and decide to insert or update to use it - Mike
  • Too much to explain in this topic for your level of knowledge. Try to google a bunch of php and mysql. htmlweb.ru/php/mysql.php addphp.ru/materials/mysql/1_5.php intop24.ru/article_15_lesson_5.php - apelsinka223

1 answer 1

If the request is through jquery, then just send the form to the processor and update or add there. I recommend in the form of a hidden field to display the id of the record, if it is - then in the handler to find out the select or update is enough to check the presence of id. Accordingly, if available, update Update ... Where id = received_id