Load MySQLl data in Modal Bootstrap

2

Hello, how could I load all the data of the person in a modal window when clicking on the button that is shown in the image called Register?

I need to click on it to load all the data, which is in a database in MySQL.

I know that it is possible with AJAX but the truth is that I do not know about it, if you can provide me with information to solve my problem, it would be very helpful.

Thank you very much.

    
asked by ByGroxD 22.02.2017 в 15:08
source

1 answer

4
$.ajax({
              dataType : 'json',
              type : 'POST',
              url : 'consulta_datos.php',
              data :{id_principal},
              async:true,
              cache:false,
              success : function(response){
                 var id=response.id;
                 var identificacion=response.identi;
                 var nombre_completo=response.nom_compl;
                 $("#id").val(id);
                 $("#identificacion").val(identificacion);
                 $("#nombre_completo").val(nombre_completo);

              },
              error : function(error) {
                console.log(error);
              }
          });

Well I recommend you use jQuery to make your Ajax to return the query data, when you create your table in the button that opens your modal, send a function that you will do in a javascript in this function that you do to send the parameter that I imagine is the id of your table you do your query and you put it in a JSON from PHP, and on the JavaScript side you receive it, and with Jquery send the values to the corresponding input, the previous code is A brief example of how you could start.

    
answered by 22.02.2017 / 17:12
source