I am trying to show several answer results. I want to show all the "follow-ups" with the same id of the "case" table, this is the Ajax that I use to put in each input the fields of the query.
function Tcaso(id){
$.ajax({
type:"POST",
data:{'id':id},
dataType:'json',
url: uri + "/caso/mostrarCasos",
}).done(function(respuesta){
$("#id").val(respuesta.id);
console.log(id);
$("#idcliente").val(respuesta.idcliente);
$("#ncuentaca").val(respuesta.ncuenta);
$("#nombreca").val(respuesta.nombre);
$("#direccionca").val(respuesta.direccion);
$("#telefonoca").val(respuesta.telefono);
$("#ciudadca").val(respuesta.ciudad);
$("#nombredecca").val(respuesta.nombredec);
$("#fallaca").val(respuesta.falla);
$("#descripcionca").val(respuesta.descripcion);
$("#resca").val(respuesta.responsable);
$("#fecca").val(respuesta.fecha);
$("#estadoca").val(respuesta.estado);
$("#solucionado").val(respuesta.solucion);
$("#idseguimiento").val(respuesta.idseguimiento);
$("#seguirme").val(respuesta.seguimiento);
$("#modalT").modal();
});
}
This is the "tracking" table that has a varchar that is the tracking and a foreign key that is the relationship between "follow-up" and "case"
You should show me examplito and big bank
<textarea type="textarea" name="seguirme" id="seguirme"></textarea>
<input type="text" name="idseguimiento" id="idseguimiento">
This is the query to show Cases
public function mostrarCasos($id)
{
$sql = "SELECT c.id, c.falla, c.responsable, c.fecha ,c.descripcion , c.solucion , c.estado , l.idcliente , l.nombre , l.ncuenta , l.nombredec , l.ciudad , l.direccion , l.telefono , s.idseguimiento , s.seguimiento FROM caso c join cliente l on c.idcliente=l.idcliente join seguimiento s on c.id=s.idcaso where id = :id LIMIT 1";
$query = $this->db->prepare($sql);
$parameters = array(':id' => $id);
$query->execute($parameters);
return $query->fetch();
}
public function mostrarCasos()
{
$id= $_POST['id'];
if (isset($id)) {
$caso = new Caso();
$caso = $caso->mostrarCasos($id);
echo json_encode($caso);
} else {
// redirect user to songs index page (as we don't have a id)
echo "Error, no ingreso el id";
}
}
I should show the two "follow-ups" of case 1 in the modal ..
I'm trying with this code and it only sends me a value.
$.each([respuesta.seguimiento], function( index, value ) {
alert( index + ": " + value );
});
define('URL_PUBLIC_FOLDER', 'public');
define('URL_PROTOCOL', '//');
define('URL_DOMAIN', $_SERVER['HTTP_HOST']);
define('URL_SUB_FOLDER', str_replace(URL_PUBLIC_FOLDER, '', dirname($_SERVER['SCRIPT_NAME'])));
define('URL', URL_PROTOCOL . URL_DOMAIN . URL_SUB_FOLDER);
/**
* Configuration for: Database
* This is the place where you define your database credentials, database type etc.
*/
define('DB_TYPE', 'mysql');
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'segurtec');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_CHARSET', 'utf8');