How do I generate a table by means of a query?

0

I have a table that is this:

<?php
session_start();
$sql = "SELECT a.profesional,a.periodo,a.cuit,a.provincia,b.id,b.cuit,b.prestador,c.periodo FROM detalles a inner join users_entidades b INNER JOIN periodo c on a.cuit=b.cuit and a.periodo=c.periodo WHERE b.id=".$_SESSION['idUsuario'];
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
?>
<div class="container">
<h4 class="text-center">Gracias por estar de vuelta <?php echo $row['prestador']; ?></h4>
<br>
<table class="table table-bordered table-sm">
  <thead>
    <tr>
      <th>Período</th>
      <th class="text-center">Cuit</th>
      <th class="text-center">Exportar</th>
    </tr>
  </thead>
  <tbody>
  <?php $sql1 = "SELECT * FROM detalles GROUP BY periodo";
        $result1 = mysqli_query($con, $sql1);
    while ($row1 = mysqli_fetch_array($result1)) {?>
    <tr>
      <th scope="row"><?php echo $row1['periodo']; ?></th>
      <td class="text-center"><?php echo $row['cuit']; ?></td>
      <td class="text-center"><a href="datos.php">PDF <?php $_SESSION['periodo']; ?></a></td>
    </tr>
    <?php } ?>
  </tbody>
</table>

And I want that when I click on the pdf file, I'm sent to a table like the one I already did. The issue is that when I click on the pdf, only the period 17/03 and not the 02 take me. The code of the table is this:

 <?php
session_start();
$sql  = "SELECT a.profesional,a.periodo,a.cuit,a.provincia,b.id,b.cuit,b.prestador,c.periodo FROM detalles a inner join users_entidades b INNER JOIN periodo c on a.cuit=b.cuit and a.periodo=c.periodo WHERE b.id=".$_SESSION['idUsuario'];
//$sql .= "GROUP BY a.periodo";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
?>
<div class="container">
    <div class="container">
        <div class="container-fluid img-responsive">
    <img src="images/oaicono.jpg" alt="" class="img-rounded">
</div>
    <div class="container-fluid">

    <h3><b>Detalle Liquidación Entidad</b></h3>
    </div>
    <div class="row">
    <div class="col-4">
        <p>Entidad:<b><?php echo $_SESSION['prestador']; ?>.</b> </p> <p>Provincia: <b><?php echo $row['provincia']; ?>.</b> </p> 
    </div>
    <div class="col-4">
        <p>Período: <b><?php echo $row['periodo']; ?></b> </p>
        <p>C.U.I.T: <b><?php echo $row['cuit']; ?></b> </p>
    </div>
    <div class="col-4">
        <p>Fecha Liq: <b><?php echo $row['periodo']."/25"; ?></b> </p>
        <p>Centro Ate: <b>Odontopraxis S.A.</b></p>
    </div>
    </div>
</div>
<br>
<div>
<h6  class="text-left"><b>Comprobantes de la entidad</b></h6>
    <table class="table text-center table-sm">
        <thead>
            <tr>
                <th>Afiliado</th>
                <th>Nº Afiliado</th>
                <th>Plan</th>
                <th>Fecha Prest.</th>
                <th>Prest.</th>
                <th>Pieza</th>
                <th>Arancel</th>
                <th>Mont. Liq. Exento</th>
                <th>Mont. Liq. Gravado</th>
                <th>Mont. Liq. IVA</th>
                <th>Motivo Debito/Credito</th>
            </tr>
        </thead>
        <tbody class="text-left">
        <?php
        $prestador = $row['profesional'];
        $periodo = $row['periodo'];
        mysqli_set_charset($con, "utf8");
        $sql1  = "SELECT * FROM detalles WHERE profesional='$prestador' AND periodo='$periodo' ORDER BY detalles.paciente ASC";
        $result1 = mysqli_query($con, $sql1);
        while ($row1 = mysqli_fetch_array($result1)) { ?>
            <tr>
                <td><b><?php echo $row1['paciente']; ?></b></td>
                <td><b><?php echo $row1['codigo'].$row1['vinc1']; ?></b></td>
                <td><b><?php echo $row1['plan']."-".$row1['desc_plan']; ?></b></td>
                <td><b><?php echo $row1['fecha']; ?></b></td>
                <td><b><?php echo $row1['codigo_prest']; ?></b></td>
                <td class="text-center"><b><?php echo $row1['pieza']; ?></b></td>
                <td class='text-right'><b><?php echo $row1['valor']; ?></b></td>
                <?php if ($row1['iva']=='S') {
                    echo "<td class='text-right'><b>--</b></td>";
                    echo "<td class='text-right'><b>".$row1['valor']."</b></td>" ;
                }else{
                    echo "<td class='text-right'><b>".$row1['valor']."</b></td>";
                    echo "<td class='text-right'><b>--</b></td>" ;
                    } ?>
                    <?php if ($row1['iva']=='S') {
                        echo "<td class='text-right'><b>".number_format($row1['valor']*(0.105),2,'.',',')."</b></td>";
                    }else{
                        echo "<td class='text-right'><b>0.00</b></td>";
                        } ?>
                <td class='text-center'><b><?php echo $row1['causa_rech']; ?></b></td>
            </tr>
        <?php } ?>
        </tbody>
        <tfoot>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td>Total</td>
                <td></td>
                <td></td>
                <td></td>
                <?php include('calculo.php'); ?>
                <td style="background-color: white;" class="text-right"><b><?php echo number_format($row['total']-$row1['gravado'],2,'.',','); ?></b></td>
                <td style="background-color: white;" class="text-right"><b><?php echo number_format($row1['gravado'],2,'.',','); ?></b></td>
                <td style="background-color: white;" class="text-right"><b><?php echo number_format($row1['gravado']*(0.105),2,'.',','); ?></b></td>
                <td style="background-color: white;"></td>
            </tr>
        </tfoot>
    </table>

[! [enter the

    
asked by Andres 29.05.2017 в 16:18
source

0 answers