<?php
require '../conexion.php';

$query = mysqli_query($conection, "SELECT * FROM cliente
WHERE estatus = 1 ORDER BY idcliente");

mysqli_close($conection);

$docu = "clientes.xls";
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=' . $docu);
header('Pragma: no-cache');
header('Expires: 0');
echo '<table border = 1>';
echo '<tr>';
echo '<th colspan = 5>Lista de clientes</th>';
echo '</tr>';
echo '<tr><th>ID</th><th>RUC</th><th>RAZON SOCIAL</th><th>CONTACTO</th><th>REFERENCIA</th></tr>';


while ($data = mysqli_fetch_array($query)) {

    echo '<tr>';
    echo '<td>' . $data["idcliente"] . '</td>';
    echo '<td>' . $data["ruc"] . '</td>';
    echo '<td>' . $data["nombre"] . '</td>';
    echo '<td>' . $data["telefono"] . '</td>';
    echo '<td>' . $data["direccion"] . '</td>';
    echo '</tr>';
}

echo '</table>'; 