Skip to main content
se añadieron 329 caracteres en el cuerpo
Origen Enlace
juandiegozb
  • 181
  • 1
  • 15
<table border = 1>
<thead>"1"><thead>
                    <tr>
      <tr>
                  <th class="text-center">*</th>
                        <th class="text-center">Concepto</th>
                            <th class="text-center">Saldo Inicial</th>
                            <th class="text-center">*mes*</th>
                        </tr>
                        </thead>
                        <tbody><tr><td>110505<<tbody><tr><td>11</td><td>110505</td><td class="text-right">4,186,295.40</td><td class="text-right">-5,173,740.00</td></tr><tr><td>110510<tr><tr><td>11</td><td>110510</td><td class="text-right">1,550,000.00</td><td class="text-right">700,000.00</td></tr><tr><td>111005<tr><tr><td>11</td><td>111005</td><td class="text-right">46,384,753.77</td><td class="text-right">3,173,347.00</td></tr><tr><td>112010<tr><tr><td>11</td><td>112010</td><td class="text-right">62,530,659.79</td><td class="text-right">-7,289,764.00</td></tr><tr><td>130505<tr><tr><td>13</td><td>130505</td><td class="text-right">2,054,821,048.47</td><td class="text-right">196,915,758.00</td></tr><tr><td>131010<tr><tr><td>13</td><td>131010</td><td class="text-right">3,540,489,179.26</td><td class="text-right">429,679,214.00</td></tr><tr><td>131020<tr><tr><td>13</td><td>131020</td><td class="text-right">73,786,179.00</td><td class="text-right">-190,122,075.00</td></tr><tr><td>132505<tr><tr><td>13</td><td>132505</td><td class="text-right">236,031,855.52</td><td class="text-right">42,472,058.00</td></tr><tr><td>138095<tr><tr><td>13</td><td>138095</td><td class="text-right">100,603,062.00</td><td class="text-right">4,145,212.00</td></tr><tr><td>159205<tr><tr><td>15</td><td>159205</td><td class="text-right">-11,976,889.00</td><td class="text-right">-347,175.00</td></tr><tr><td>159215<tr><tr><td>15</td><td>159215</td><td class="text-right">-19,502,772.00</td><td class="text-right">-1,508,445.00</td></tr><tr><td>159220<tr><tr><td>15</td><td>159220</td><td class="text-right">-122,900,973.00</td><td class="text-right">-7,706,684.00</td></tr><tr><td>170595<tr><tr><td>17</td><td>170595</td><td class="text-right">25,769,596.00</td><td class="text-right">-814,792.00</td></tr></tbody></tabletable>
<?php

            echo "<table class=\"table table-sm\">";
            echo "<thead>
                    <tr>
                        <th class ='text-center'>*</th>
                        <th class ='text-center'>Concepto</th>
                        <th class ='text-center'>Saldo Inicial</th>
                        <th class ='text-center'>*mes*</th>
                    </tr>
                    </thead>
                    <tbody>";
            

            foreach($datos['datosXactivos'] as $clave => $datoActivo):
                    echo "<tr>";
                    echo "<td>".$datoActivo->grupo."</td>"; //Este es el grupo que identifica.
                    echo "<td>".$datoActivo->subcuenta."</td>";
                    echo "<td class ='text-right'>".number_format($datoActivo->saldo_inicial,2)."</td>";
                    echo "<td class = 'text-right'>".number_format($datoActivo->saldo_final,2)."</td>";
                    echo "</tr>";
            endforeach;

            echo "</tbody>";
            echo "</table>";
        ?>
<table border = 1>
<thead>
                        <tr>
                            <th class="text-center">Concepto</th>
                            <th class="text-center">Saldo Inicial</th>
                            <th class="text-center">*mes*</th>
                        </tr>
                        </thead>
                        <tbody><tr><td>110505</td><td class="text-right">4,186,295.40</td><td class="text-right">-5,173,740.00</td></tr><tr><td>110510</td><td class="text-right">1,550,000.00</td><td class="text-right">700,000.00</td></tr><tr><td>111005</td><td class="text-right">46,384,753.77</td><td class="text-right">3,173,347.00</td></tr><tr><td>112010</td><td class="text-right">62,530,659.79</td><td class="text-right">-7,289,764.00</td></tr><tr><td>130505</td><td class="text-right">2,054,821,048.47</td><td class="text-right">196,915,758.00</td></tr><tr><td>131010</td><td class="text-right">3,540,489,179.26</td><td class="text-right">429,679,214.00</td></tr><tr><td>131020</td><td class="text-right">73,786,179.00</td><td class="text-right">-190,122,075.00</td></tr><tr><td>132505</td><td class="text-right">236,031,855.52</td><td class="text-right">42,472,058.00</td></tr><tr><td>138095</td><td class="text-right">100,603,062.00</td><td class="text-right">4,145,212.00</td></tr><tr><td>159205</td><td class="text-right">-11,976,889.00</td><td class="text-right">-347,175.00</td></tr><tr><td>159215</td><td class="text-right">-19,502,772.00</td><td class="text-right">-1,508,445.00</td></tr><tr><td>159220</td><td class="text-right">-122,900,973.00</td><td class="text-right">-7,706,684.00</td></tr><tr><td>170595</td><td class="text-right">25,769,596.00</td><td class="text-right">-814,792.00</td></tr></tbody></table
<?php

            echo "<table class=\"table table-sm\">";
            echo "<thead>
                    <tr>
                        <th class ='text-center'>Concepto</th>
                        <th class ='text-center'>Saldo Inicial</th>
                        <th class ='text-center'>*mes*</th>
                    </tr>
                    </thead>
                    <tbody>";
            

            foreach($datos['datosXactivos'] as $clave => $datoActivo):
                    echo "<tr>";
                    echo "<td>".$datoActivo->subcuenta."</td>";
                    echo "<td class ='text-right'>".number_format($datoActivo->saldo_inicial,2)."</td>";
                    echo "<td class = 'text-right'>".number_format($datoActivo->saldo_final,2)."</td>";
                    echo "</tr>";
            endforeach;

            echo "</tbody>";
            echo "</table>";
        ?>
<table border = "1"><thead>
                    <tr>
                        <th class="text-center">*</th>
                        <th class="text-center">Concepto</th>
                        <th class="text-center">Saldo Inicial</th>
                        <th class="text-center">*mes*</th>
                    </tr>
                    </thead>
                    <tbody><tr><td>11</td><td>110505</td><td class="text-right">4,186,295.40</td><td class="text-right">-5,173,740.00</td></tr><tr><td>11</td><td>110510</td><td class="text-right">1,550,000.00</td><td class="text-right">700,000.00</td></tr><tr><td>11</td><td>111005</td><td class="text-right">46,384,753.77</td><td class="text-right">3,173,347.00</td></tr><tr><td>11</td><td>112010</td><td class="text-right">62,530,659.79</td><td class="text-right">-7,289,764.00</td></tr><tr><td>13</td><td>130505</td><td class="text-right">2,054,821,048.47</td><td class="text-right">196,915,758.00</td></tr><tr><td>13</td><td>131010</td><td class="text-right">3,540,489,179.26</td><td class="text-right">429,679,214.00</td></tr><tr><td>13</td><td>131020</td><td class="text-right">73,786,179.00</td><td class="text-right">-190,122,075.00</td></tr><tr><td>13</td><td>132505</td><td class="text-right">236,031,855.52</td><td class="text-right">42,472,058.00</td></tr><tr><td>13</td><td>138095</td><td class="text-right">100,603,062.00</td><td class="text-right">4,145,212.00</td></tr><tr><td>15</td><td>159205</td><td class="text-right">-11,976,889.00</td><td class="text-right">-347,175.00</td></tr><tr><td>15</td><td>159215</td><td class="text-right">-19,502,772.00</td><td class="text-right">-1,508,445.00</td></tr><tr><td>15</td><td>159220</td><td class="text-right">-122,900,973.00</td><td class="text-right">-7,706,684.00</td></tr><tr><td>17</td><td>170595</td><td class="text-right">25,769,596.00</td><td class="text-right">-814,792.00</td></tr></tbody></table>
<?php

            echo "<table class=\"table table-sm\">";
            echo "<thead>
                    <tr>
                        <th class ='text-center'>*</th>
                        <th class ='text-center'>Concepto</th>
                        <th class ='text-center'>Saldo Inicial</th>
                        <th class ='text-center'>*mes*</th>
                    </tr>
                    </thead>
                    <tbody>";
            

            foreach($datos['datosXactivos'] as $clave => $datoActivo):
                    echo "<tr>";
                    echo "<td>".$datoActivo->grupo."</td>"; //Este es el grupo que identifica.
                    echo "<td>".$datoActivo->subcuenta."</td>";
                    echo "<td class ='text-right'>".number_format($datoActivo->saldo_inicial,2)."</td>";
                    echo "<td class = 'text-right'>".number_format($datoActivo->saldo_final,2)."</td>";
                    echo "</tr>";
            endforeach;

            echo "</tbody>";
            echo "</table>";
        ?>
Origen Enlace
juandiegozb
  • 181
  • 1
  • 15

agregar nueva fila a tabla en php

Resulta que estoy haciendo un llamado a la base de datos, con el fin de poder sacar unos registros esos registros los recorro mediante la funcion foreach envevido en un , todo me funciona bien: el codigo que tengo es el siguiente:

<table border = 1>
<thead>
                        <tr>
                            <th class="text-center">Concepto</th>
                            <th class="text-center">Saldo Inicial</th>
                            <th class="text-center">*mes*</th>
                        </tr>
                        </thead>
                        <tbody><tr><td>110505</td><td class="text-right">4,186,295.40</td><td class="text-right">-5,173,740.00</td></tr><tr><td>110510</td><td class="text-right">1,550,000.00</td><td class="text-right">700,000.00</td></tr><tr><td>111005</td><td class="text-right">46,384,753.77</td><td class="text-right">3,173,347.00</td></tr><tr><td>112010</td><td class="text-right">62,530,659.79</td><td class="text-right">-7,289,764.00</td></tr><tr><td>130505</td><td class="text-right">2,054,821,048.47</td><td class="text-right">196,915,758.00</td></tr><tr><td>131010</td><td class="text-right">3,540,489,179.26</td><td class="text-right">429,679,214.00</td></tr><tr><td>131020</td><td class="text-right">73,786,179.00</td><td class="text-right">-190,122,075.00</td></tr><tr><td>132505</td><td class="text-right">236,031,855.52</td><td class="text-right">42,472,058.00</td></tr><tr><td>138095</td><td class="text-right">100,603,062.00</td><td class="text-right">4,145,212.00</td></tr><tr><td>159205</td><td class="text-right">-11,976,889.00</td><td class="text-right">-347,175.00</td></tr><tr><td>159215</td><td class="text-right">-19,502,772.00</td><td class="text-right">-1,508,445.00</td></tr><tr><td>159220</td><td class="text-right">-122,900,973.00</td><td class="text-right">-7,706,684.00</td></tr><tr><td>170595</td><td class="text-right">25,769,596.00</td><td class="text-right">-814,792.00</td></tr></tbody></table

Este codigo solo es para mostrar la tabla (html)

con php es el siguiente :

<?php

            echo "<table class=\"table table-sm\">";
            echo "<thead>
                    <tr>
                        <th class ='text-center'>Concepto</th>
                        <th class ='text-center'>Saldo Inicial</th>
                        <th class ='text-center'>*mes*</th>
                    </tr>
                    </thead>
                    <tbody>";
            

            foreach($datos['datosXactivos'] as $clave => $datoActivo):
                    echo "<tr>";
                    echo "<td>".$datoActivo->subcuenta."</td>";
                    echo "<td class ='text-right'>".number_format($datoActivo->saldo_inicial,2)."</td>";
                    echo "<td class = 'text-right'>".number_format($datoActivo->saldo_final,2)."</td>";
                    echo "</tr>";
            endforeach;

            echo "</tbody>";
            echo "</table>";
        ?>

Lo que intento hacer es como ustedes observan la columna de concepto tiene un consecutivo donde los dos primeros digitos hacen un grupo 11 - 13 - 15 -17.

Lo que deseo hacer es que cada vez que termine un grupo ejemplo los 4 primeros campos me agregue otra fila siguiente con una descricion que diga total y la suma de los valores del campo mes

Lo he intentado de muchas formas, pero no sé como agregar una columna nueva con eso cada vez que termina un grupo.

Muchas gracias