You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
2.6 KiB

<?php
/**
* Use an HTML form to create a new entry in the
* users table.
*
*/
require './config.php';
require './common.php';
/**
* Esto es para comprobar si existe la BD
*/
try {
$conexion = new PDO( $dsn, $username, $password, $options );
include './templates/header.php';
$sql = "SELECT *
FROM carburante
ORDER BY fecha DESC LIMIT 10" ;
$statement = $conexion->prepare($sql);
$statement->execute();
$result = $statement->fetchAll();
?>
<section class="principal">
<div class="container">
<section>
<h2>Últimos repostajes</h2>
<table>
<thead>
<tr>
<th>#</th>
<th>Fecha</th>
<th>Vehículo</th>
<th>Kilómetros</th>
<th>Litros</th>
<th>Descuento</th>
<th>Precio/litro</th>
<th>Importe</th>
</tr>
</thead>
<tbody>
<?php foreach ($result as $row) : ?>
<tr>
<td><?php echo escape($row["identificador"]); ?></td>
<td><?php echo escape($row["fecha"]); ?></td>
<td><?php echo escape($row["vehiculo"]); ?></td>
<td><?php echo escape($row["kms"]); ?></td>
<td><?php echo escape(str_replace('.', ',',$row["litros"])); ?></td>
<td><?php echo escape(str_replace('.', ',',$row["descuento"])); ?></td>
<td><?php echo escape(str_replace('.', ',',$row["precioxlitro"])); ?></td>
<td><?php echo escape(str_replace('.', ',',$row["importe"])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
</div>
</section>
<!-- <a href = '../install.php'><strong>Crear base de datos</strong></a> -->
<?php include './templates/footer.php';
} catch( PDOException $error ) {
require './templates/header.php';
?>
<section id='four' class='main style2 special'>
<div class='container'>
<header class='major'>
<h2>Base de datos inexistente</h2>
</header>
<section>
<p>La base de datos no existe. ¿quieres inicializarla?</p>
<ul class='actions special'>
<li><a href='/install.php'><strong>Crear base de datos</strong></a></li>
</ul>
</section>
</div>
</section>
<?php require './templates/footer.php';
}
?>