Insert in mysql

0

I am working with cordova Do this this function that brings me the data of a mysql database. Using a php file

function traer() {
        $.getJSON('http://127.0.0.1/bd/traer.php',
            function(data){
                var x=data.length;
                alert(x);
                var tb = "";
                tb = tb + "<table>";
                for (var i = 0; i < x; i++) {
                    tb = tb + "<tr><td>"+data[i].Id + "</td><td>" + data[i].Nombre +"</td></tr>";
                }
                tb = tb + "</table>";
                 //document.getElementById("dato1").innerHTML = data[0].Id;
                //document.getElementById("dato2").innerHTML =  data[0].Nombre;
                 //document.getElementById("dato3").innerHTML = data[0].Apellido;
                document.getElementById("demo").innerHTML = tb;

            }
              );
    }

The php file loaded in xampp is as follows

<?php 
    $host = "127.0.0.1";
    $usuario = "root";
    $pass = "";
    $bd = "test001";

    $mysqli = new mysqli($host, $usuario, $pass , $bd);
    $mysqli->set_charset("utf8");

    $datos= array();

    $resultado = $mysqli->query("SELECT * FROM datos");

    while ($obj = mysqli_fetch_object($resultado)) {
            $datos[] = array('Id' => $obj->Id,
                          'Nombre' => $obj->Nombre,
                          'Apellido' => $obj->Apellido
            );
    }
        echo '' . json_encode($datos) . ''; 

? >

then the contrui con cordova

cordova build android

It works correctly, but how can I insert an entry in the database?

    
asked by CesarG 28.02.2018 в 20:37
source

0 answers