Greetings, I have the following problem, it turns out that I am making a query to my database with different fields, and I am getting the results as follows.
while($fila=mysqli_fetch_array($resultados, MYSQLI_ASSOC)){
echo "<table class= main-container>";
echo $fila ['COD_CONSULTA']. "";
echo $fila ['CED_PAC']. "";
echo $fila ['NOM_PAC']. "";
echo $fila ['APE_PAC']. "";
echo $fila ['SEX_PAC']. "";
echo $fila ['ALT_PAC']. "";
echo $fila ['PESO_PAC']. "";
echo $fila ['FECHA']. "";
echo $fila ['TIPO_CONSULTA']. "";
echo $fila ['SINTOMAS']. "";
echo $fila ['OBSERV']. "";
echo $fila ['HIS_PAC']. "";
echo $fila ['MEDI_PAC']. "";
echo $fila ['OPERADO']. "";
echo $fila ['ALERGIAS']. "</table>";
echo "<br> ";
echo "<br> ";
}
mysqli_close($conexion);
}
Well, I have a table created in HTML and I want those results to be shown to me in the table so I can apply a CSS style and make it look nice Does anyone know how?
This is my table.
<div id="main-container">
<table>
<thead>
<tr>
<th>Codigo Consulta</th><th>Cedula</th><th>Nombres</th><th>Apellidos</th><th>Estatura</th><th>Peso</th><th>Tipo consulta</th><th>Sintomas</th><th>Observaciones</th><th>Medicamentos actuales</th><th>Alergias</th>
</tr>
</thead>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>
</div>
EDIT: This is the code of the whole page in case someone wants to see it (Here I still do not have the table added, if someone can help me with that, because I have in the first place a box of search and when making the query reload the page and shows the query)
<?php
function ejecuta_consulta($labusqueda){
include("conexiond.php");
$conexion= mysqli_connect($db_host,$db_usuario,$db_contra);
if(mysqli_connect_errno()){
echo "Fallo al conectar con la base de datos";
exit();
}
mysqli_select_db($conexion,$db_nombre) or die ("No se encuentra la base de datos.");
$consulta = "SELECT datosbasicos.CED_PAC,datosbasicos.NOM_PAC,datosbasicos.APE_PAC,datosbasicos.SEX_PAC,datosmedicos.COD_CONSULTA,datosmedicos.ALT_PAC,datosmedicos.PESO_PAC,datosmedicos.FECHA,datosmedicos.TIPO_CONSULTA,datosmedicos.SINTOMAS,datosmedicos.OBSERV,datosmedicos.HIS_PAC,datosmedicos.MEDI_PAC,datosmedicos.OPERADO,datosmedicos.ALERGIAS FROM datosbasicos INNER JOIN datosmedicos ON datosbasicos.CED_PAC=datosmedicos.CED_PAC WHERE datosbasicos.CED_PAC LIKE '%$labusqueda%'";
$resultados = mysqli_query($conexion,$consulta);
while($fila=mysqli_fetch_array($resultados, MYSQLI_ASSOC)){
echo "<table class= main-container>";
echo $fila ['COD_CONSULTA']. "";
echo $fila ['CED_PAC']. "";
echo $fila ['NOM_PAC']. "";
echo $fila ['APE_PAC']. "";
echo $fila ['SEX_PAC']. "";
echo $fila ['ALT_PAC']. "";
echo $fila ['PESO_PAC']. "";
echo $fila ['FECHA']. "";
echo $fila ['TIPO_CONSULTA']. "";
echo $fila ['SINTOMAS']. "";
echo $fila ['OBSERV']. "";
echo $fila ['HIS_PAC']. "";
echo $fila ['MEDI_PAC']. "";
echo $fila ['OPERADO']. "";
echo $fila ['ALERGIAS']. "</table>";
echo "<br> ";
echo "<br> ";
}
mysqli_close($conexion);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sistema de historias médicas - Dr. Darling Davila</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/estilo.css">
<link href="https://fonts.googleapis.com/css?family=Lato|Roboto" rel="stylesheet">
</head>
<body>
<?php
$mibusqueda=$_GET["buscar"];
$mipag=$_SERVER["PHP_SELF"];
if($mibusqueda!=NULL){
ejecuta_consulta($mibusqueda);
}else{
echo ("<form action='". $mipag . "' method='GET'>
<img src='imagenes/header.png'>
<h2>Busqueda de paciente</h2>
<div class='contenedor'>
<input type='text' name='buscar' class='input-100 text-center inline-block col-md-6 btn-enviar espacio-arriba'></label>
<input type='submit' name='enviando' value='Consulta' class='text-center inline-block col-md-12 espacio-arriba btn-enviar'>
</div>
</form>");
}
?>
<!--</body> // Esta seria la tabla que me debe aparecer al hacer la consulta, no se como agregarla.
</html>
<div id="main-container">
<table>
<thead>
<tr>
<th>Codigo Consulta</th><th>Cedula</th><th>Nombres</th><th>Apellidos</th><th>Estatura</th><th>Peso</th><th>Tipo consulta</th><th>Sintomas</th><th>Observaciones</th><th>Medicamentos actuales</th><th>Alergias</th>
</tr>
</thead>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>
</div>