Good I would like you to help me I'm making them show my query of a column but it is dynamic is to say that some months appear and some do not, according to the range they chose in the form.
Since I do not know which columns are going to be shown with this code in php, the dynamic column generates me.
<?php
include("config.php");
/* Tu proceso de conexión, consulta y resultado */
$sql= "EXEC Sp_DetalleObservacion 6,'','','','','','','' ";
$result = sqlsrv_query($conn,$sql) or die("Couldn't execut query");
if(!$result){
echo "Ocurrio un error en la consulta";
}else{
$tabla ="<table class='table table-bordered text-center' id='tablenombrehistorico'>";
$tabla .="<thead>";
$tabla .= "<tr>";
$i = 0;
while ($data = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC)) {
if ($i == 0) {
foreach($data as $key => $value) {
$tabla .="<th scope='col' style='text-align: center;background-color: #054AC4;color: #fff'>" . $key . "</th>";
}
$tabla .="</tr>";
$tabla .="</thead>";
$tabla .="<tbody>";
}
$tabla .="<tr>";
foreach($data as $key => $value) {
if($value=="ZONA I - ADONIAS SILVA" or $value=="ZONA II - DANNY CANELA" or $value=="ZONA III - SANDRO CHAVEZ")
{
$tabla .="<td style='background: yellow'>".$value."</td>";
}
/*
else if($value=="0.00")
{
$tabla .="<td style='background: yellow'>".$value."</td>";
}
*/
else
{
$tabla .="<td>".$value."</td>";
}
//$tabla .="<td>".$value."</td>";
}
$tabla .="</tr>";
$i++;
}
$tabla .="</tbody>";
$tabla .="</table>";
echo $tabla;
}
?>
currently is as well as the image.
I would like something like this to be done.
This is my form.
basically if I choose an example date of January or March it should be shown only of that date that already makes it dynamic but what I want is to paint as well as the image.
rspuesa
<?php
include("config.php");
/* Tu proceso de conexión, consulta y resultado */
$sql= "EXEC Sp_DetalleObservacion 6,'','','','','','','' ";
$result = sqlsrv_query($conn,$sql) or die("Couldn't execut query");
if(!$result){
echo "Ocurrio un error en la consulta";
}else{
$tabla ="<table class='table table-bordered text-center' id='tablenombrehistorico'>";
$tabla .="<thead>";
$tabla .= "<tr>";
$i = 0;
while ($data = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC)) {
if ($i == 0) {
$counter = 0;
foreach($data as $key => $value) {
$tabla .="<th scope='col' style='text-align: center;background-color: #054AC4;color: #fff'>" . $key . "</th>";
$counter++;
if ($counter % 3 == 0) {
$tabla .= "<th style='background: black'> </th>";
}
}
$tabla .="</tr>";
$tabla .="</thead>";
$tabla .="<tbody>";
}
$counter = 0;
foreach($data as $key => $value) {
if($value=="ZONA I - ADONIAS SILVA" or $value=="ZONA II - DANNY CANELA" or $value=="ZONA III - SANDRO CHAVEZ")
{
$tabla .= "<tr style='background: yellow'>";
} elseif ($key == 'agencia') {
$tabla .="<tr>";
}
$tabla .="<td>".$value."</td>";
}
$tabla .="</tr>";
$i++;
}