How to do select in postgres from an html field and use the return to fill the other fields?

2

Basically I do not have any experience with html, php or javascrip and I'm trying to get around what I'm asked here. The problem is this:

I have to make a registration page where the user selects a base year and if the record exists in the database (postgres) it fills the fields with the data to update, and if there are no fields remain empty to add the register. These are annual parameters, so you can conclude that you can only have one registration per year. Note: All via Post.

I already have the code that connects to DB, only include where I need it, and I also have a slight notion of sql commands, it's not that difficult. I really wanted guidance, I have no idea what to research or where to start researching. I do not want codes or anything (unless it's for example, it helps a little), I really wanted to know what I need to learn to be able to do it, why is that a very general question.

    
asked by anonymous 03.04.2017 / 14:26

1 answer

1

I advise you to read AJAX with JQUERY.

The stream will look something like this:

  • User types the date.
  • With JQUERY and its events (onkeypress, up etc) it checks if the date is complete.
  • If it is complete, make a call to a PHP script using ajax ( link ).
  • In this PHP script, you will do the query searching in your database (SELECT * FROM table WHERE data = '$ data').
  • If this query returns a row or not, create a JSON with the result
  • With JSON created, just give an "echo" to it itself Eg: echo $ json.
  • With this our ajax will receive this JSON in return, (function success), in return you make the treatment of the data. Tip: Read on the W3SCHOOLS website.
  • Treating the data let's set the values in the inpunts we want.
  • A basic example making a similar flow: link

        
    05.04.2017 / 02:45