Beispiel #1
0
function generar_resultado($params)
{
    extract($params);
    if (pg_num_rows($res) > 0) {
        ?>
        <p><table border="1" style="margin:auto">
            <thead><?php 
        $href = "index.php?";
        foreach ($columnas as $k => $v) {
            $sufijo = sentido($k, $orden, $sentido);
            if ($k == $orden) {
                $flecha = $sentido == "asc" ? " ▴" : " ▾";
            } else {
                $flecha = "";
            }
            ?>
                    <th>
                        <a href="<?php 
            echo "{$href}orden={$k}&sentido={$sufijo}";
            ?>
">
                            <input type="button"
                                   value="<?php 
            echo $v['bonito'] . $flecha;
            ?>
"
                                   <?php 
            echo resaltar($k, $orden);
            ?>
 />
                        </a>
                    </th><?php 
        }
        ?>
                <th colspan="2">Operaciones</th>
            </thead>
            <tbody><?php 
        for ($i = 0; $i < pg_num_rows($res); $i++) {
            $fila = pg_fetch_assoc($res, $i);
            ?>
                    <tr><?php 
            foreach ($columnas as $k => $v) {
                ?>
                            <td <?php 
                echo alinear($v);
                ?>
 >
                                <?php 
                echo $fila[$k];
                ?>
                            </td><?php 
            }
            ?>
                        <td>
                            <form action="modificar.php" method="get">
                                <input type="hidden" name="id"
                                       value="<?php 
            echo $fila['id'];
            ?>
" />
                                <input type="submit" value="Modificar" />
                            </form>
                        </td>
                        <td>
                            <form action="borrar.php" method="get">
                                <input type="hidden" name="id"
                                       value="<?php 
            echo $fila['id'];
            ?>
" />
                                <input type="submit" value="Borrar" />
                            </form>
                        </td>
                    </tr><?php 
        }
        ?>
            </tbody>
        </table></p><?php 
    } else {
        ?>
        <h3>La búsqueda no ha devuelto ningún resultado</h3><?php 
    }
}
Beispiel #2
0
function generar_resultado($params, $bol = false)
{
    extract($params);
    if (pg_num_rows($res) > 0) {
        ?>
        <table border="1" style="margin: auto;">
            <thead><?php 
        $href = "index.php?";
        foreach ($columnas as $k => $v) {
            if (isset($v['mostrar'])) {
                $sufijo = sentido($k, $orden, $sentido);
                ?>
                        <th>
                            <a href="<?php 
                echo "{$href}orden={$k}&sentido={$sufijo}";
                ?>
">
                                <input type="button" value="<?php 
                echo $v['bonito'];
                ?>
" <?php 
                echo resaltar($k, $orden);
                ?>
 >
                            </a>
                            <?php 
                echo $k == $orden ? icono_sentido($sentido) : "";
                ?>
                        </th><?php 
            }
        }
        ?>
                <th colspan="2" >Operaciones</th>
            </thead>
            <tbody><?php 
        for ($i = 0; $i < pg_num_rows($res); $i++) {
            $fila = pg_fetch_assoc($res, $i);
            ?>
                    <tr><?php 
            foreach ($columnas as $k => $v) {
                if (isset($v['mostrar'])) {
                    if (isset($v['formato'])) {
                        $valor = $fila[$v['formato']];
                    } else {
                        $valor = $fila[$k];
                    }
                    ?>
                                <td <?php 
                    echo alinear($v);
                    ?>
><?php 
                    echo $valor;
                    ?>
</td><?php 
                }
            }
            if ($bol) {
                ?>
                        <td colspan="2">
                            <form action="index.php" method="get">
                                <input type="hidden" name="codigo" value="<?php 
                echo trim($fila['codigo']);
                ?>
" />
                                <label for="cantidad">Cantidad</label>
                                <input type="number" name="cantidad" value="0" min="0" max="<?php 
                echo $fila['existencias'];
                ?>
"/> 
                                <input type="submit" value="Añadir al carrito" />
                            </form>
                        </td>

                        <?php 
            } else {
                ?>
                        <td>
                            <form action="modificar.php" method="get">
                                <input type="hidden" name="id" value="<?php 
                echo $fila['id'];
                ?>
" />
                                <input type="submit" value="Modificar" />
                            </form>
                        </td>
                        <td>
                            <form action="borrar.php" method="get">
                                <input type="hidden" name="id" value="<?php 
                echo $fila['id'];
                ?>
" />
                                <input type="submit" value="Borrar" />
                            </form>
                        </td>
                    </tr><?php 
            }
        }
        ?>
            </tbody>
        </table><?php 
        paginacion($href, $npag, $npags);
        ?>
        <br /><?php 
    } else {
        ?>
        <h3>La búsqueda no ha dado ningún resultado.</h3><?php 
    }
}