Export DB to Excel

1

Well, I'm doing a data recovery from my bank to Excel, it's working perfect so far, so it's having a limit, it's not making the impression of my whole table! So getting the 2,800 initial users and there are more than 9k could you help me?

Could you check please?

    <?php
session_start();
?>

<?php
@ini_set('display_errors', 0);
header('Content-type: text/html; charset=utf-8'); 
date_default_timezone_set("Brazil/East");
        //Sql_visitantes
            $nome_usuario = $_SESSION["sess_name_user_vendas"];
            $id_conta = $_SESSION["id_conta_vendas"];
            $id_usuario = $_SESSION["id_usuario_vendas"] ;
            $nivel = $_SESSION["tipo_acesso_vendas"];   
            $tipo_conta = $_SESSION["tipo_conta_vendas"];
            $id_evento = $_SESSION["sess_fair_vendas"];

    //sql_contatos
  

// Include the connection

include ("../connection.php");

// Nome do Arquivo do Excel que será gerado
$arquivo = 'banco_dados_algoritech.xls';

// Criamos uma tabela HTML com o formato da planilha para excel
$tabela = '<table border="1">';
$tabela .= '<tr><b> LISTA DB ALGORITECH 2017 </b></tr>';
//$tabela .= '<td colspan="2">'.$evento.' - '.$data_inicio.' a '.$data_final.'</tr>';
//$tabela .= '</tr>';
//$tabela .= '<tr></tr>'; 
$tabela .= '<tr>';
$tabela .= '<td><b>NOME</b></td>';
$tabela .= '<td><b>ID</b></td>';
$tabela .= '<td><b>TIPO DE CREDENCIAMENTO</b></td>';
$tabela .= '<td><b>FONE</b></td>';
$tabela .= '<td><b>CELULAR</b></td>';
$tabela .= '<td><b>CPF</b></td>';
$tabela .= '<td><b>CNPJ</b></td>';
$tabela .= '<td><b>FUNÇÃO</b></td>';
$tabela .= '<td><b>EMPRESA</b></td>';
$tabela .= '<td><b>ID USUARIO</b></td>';
$tabela .= '<td><b>ID CONTA</b></td>';
$tabela .= '</tr>';
  

// Pulling Data from the Database

$sql_visitantes=mysql_query("SELECT * FROM visitantes WHERE id_conta = '$id_conta' AND id_evento = '$id_evento' ORDER BY 'nome' ASC;",$connection);


        while ($loop_visitantes=mysql_fetch_array($sql_visitantes)) {
$nome_usuario = ucfirst(strtoupper ($loop_visitantes ["nome"]));    
$id_conta = ucfirst(strtoupper ($loop_visitantes ["id"]));  
$id_usuario = ($loop_visitantes ["tipo_credencial"]);   
$tipo_conta = ucfirst(strtoupper ($loop_visitantes ["tipo_conta"]));    
$fone = ($loop_visitantes ["fone"]);    
$cpf = ($loop_visitantes ["cpf"]);
$cnpj = ($loop_visitantes ["cnpj"]);
$funcao = ($loop_visitantes ["funcao"]);
$nome_fantasia = ($loop_visitantes ["nome_fantasia"]);
$id_evento = ($loop_visitantes["sess_fair_vendas"]); 


$tabela .= '<tr>';
$tabela .= '<td>'.$nome_usuario.'</td>';
$tabela .= '<td>'.$id_conta.'</td>';
$tabela .= '<td>'.$id_usuario.'</td>';
$tabela .= '<td>'.$tipo_conta.'</td>'; 
$tabela .= '<td>'.$fone.'</td>';
$tabela .= '<td>'.$cpf.'</td>';
$tabela .= '<td>'.$cnpj.'</td>';
$tabela .= '<td>'.$funcao.'</td>';
$tabela .= '<td>'.$nome_fantasia.'</td>';
$tabela .= '<td>'.$email.'</td>'; 
$tabela .= '<td>'.$id_usuario_contato.'</td>';

$ table. = ''; }

$ table. = '';

  

// Force Generated File Download

header ('Cache-Control: no-cache, must-revalidate');
header ('Pragma: no-cache');
header('Content-Type: application/x-msexcel');
header ("Content-Disposition: attachment; filename=\"{$arquivo}\"");
header ("Content-Description: PHP Generated Data" );
echo $tabela;
?>
    
asked by anonymous 21.06.2017 / 17:31

1 answer

1

This usually occurs when the PHP or MySQL limits are exhausted, try to increase the upload and post limits on your php.ini:

upload_max_filesize = 20M
post_max_size = 20M

You can do this directly in your .htaccess folder that is running the file, depending on the settings and permissions of your hosting you may need to contact your hosting provider to increase the values, use an info.php file ( inside the directory) to check if the values have been increased, so create an info.php file inside the directory with this code:

<?php
phpinfo(); 
?> 

Now open the file link in your browser and check if the limits have really your MySQL server next to your hosting, if you are the administrator or root user you can do this personally in my.cnf of your MySQL by setting the values "memory_limit" and "wait_timeout" (do not forget to perform a backup), restart your server MySQL after the modification, if the problem persists enable debugging and check your logs for further analysis.

    
22.06.2017 / 00:42