Dear programmers, I come to you based on the following problem. I work on a system and I'm using Datatables. So far I have not had major problems, but now I'm with one that is pulling green hairs. I have in my mysql Database, a table called laboratories, where records with the id of related fields are kept. In this particular case, the region and city ids of a laboratory are saved. At the time of creating the table in datatables, obviously it generates the id of region and city on screen but I need to get these id in a php variable to consult in their respective tables (region and city) the names of them and thus reflect them on screen . I put part of my code where I make the calls.
Javascript code
$(document).ready(function() {
$('#listado').dataTable({
"ajax": "buscalab.php",
"columns" : [
{
"sClass": "alignRight",
"data" : "region"
}, {
"sClass": "alignRight",
"data" : "ciudad"
}
Php code in search.php
$sql = "SELECT * FROM clientes WHERE tipo = 'lab'";
$resultado = mysqli_query($conexion, $sql);
if (!$resultado){
die("Error");
}else{
while ($data = mysqli_fetch_assoc($resultado)){
$arreglo["data"][]= $data;
}
echo json_encode($arreglo);
}
mysqli_free_result($resultado);
mysqli_close($conexion);
I enclose an image of how it looks now
I appreciate any help or guidance in this regard. Greetings to all.