FUNCION CON ARRAYS NO DEVUELVE DATOS
Publicado por Jonathan (40 intervenciones) el 06/01/2020 15:55:58
Estimados
Tengo las siguientes funciones en PHP
Mediante Ajax busco pasar las variables obtenidas
La funcion resultados si funciona, pero la función clientes no, ahora si yo borro la funcion resultados si funciona la funcion clientes, porque puede estar pasando eso ?, o de que otra forma puedo realizar la busqueda, de antemano muchas gracias.
Tengo las siguientes funciones en PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public function resultados(){
if(!(empty($_POST['patente']))){
$patente = $_POST['patente'];
}
$sqlQuery = "SELECT * FROM vehiculos WHERE patente='$patente'";
$resultados = mysqli_query($this->db_conectada , $sqlQuery);
$totalresultados = mysqli_num_rows($resultados);
if($totalresultados > 0) {
while ($fila = mysqli_fetch_assoc($resultados)) {
$vin = $fila['vin'];
$marca = $fila['marca'];
$modelo = $fila['modelo'];
$motor = $fila['motor'];
$periodo = $fila['periodo'];
$combustible = $fila['combustible'];
$HTML = [$vin,$marca,$modelo,$motor,$periodo,$combustible];
}
}else{
$HTML = ['Sin Datos','Sin Datos','Sin Datos','Sin Datos','Sin Datos','Sin Datos'];
}
return $HTML;
}
public function cliente(){
if(!(empty($_POST['rut']))){
$rut = $_POST['rut'];
}
$sqlQuery = "SELECT * FROM clientes WHERE rut='19.064.128-7'";
$resultados = mysqli_query($this->db_conectada , $sqlQuery);
$totalresultados = mysqli_num_rows($resultados);
if($totalresultados > 0) {
while ($fila = mysqli_fetch_assoc($resultados)) {
$nombre = $fila['nombre'];
$telefono = $fila['telefono'];
$HTML = [$nombre,$telefono];
}
}else{
$HTML = ['Sin Datos','Sin Datos'];
}
return $HTML;
}
Mediante Ajax busco pasar las variables obtenidas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function listado_vehiculos() {
$('.searchResult').html('<div id="loading">Cargando .....</div>');
var action = 'fetch_data';
var patente = document.getElementById("patente").value;
$.ajax({
url:"ordenes.php",
method: "POST",
dataType: "json",
data:{ action:action,patente:patente},
success:function(data){
$('#vin').val(data.html[0]);
$('#marca').val(data.html[1]);
$('#modelo').val(data.html[2]);
$('#motor').val(data.html[3]);
$('#periodo').val(data.html[4]);
$('#combustible').val(data.html[5]);
}
});
}
function listado_clientes() {
var action = 'fetch_data';
var rut = document.getElementById("rut").value;
$.ajax({
url:"ordenes.php",
method: "POST",
dataType: "json",
data:{ action:action,rut:rut},
success:function(data){
$('#nombre').val(data.html2[0]);
$('#telefono').val(data.html2[0]);
}
});
}
La funcion resultados si funciona, pero la función clientes no, ahora si yo borro la funcion resultados si funciona la funcion clientes, porque puede estar pasando eso ?, o de que otra forma puedo realizar la busqueda, de antemano muchas gracias.
Valora esta pregunta


0