Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera , to com um problema aqui ..
to com um script pra pegar todos pedidos da base de dados e gravar num txt ...
so que so ta gravando a ultima coluna do banco qual o erro ..
ai vai o script
<?php
set_time_limit(0);
#######################################BAIXAR TODOS ###########################################################
if($_GET['baixar'] == "Baixar Todos Pedidos"){
@mysql_connect("localhost","root","");
@mysql_select_db("");
$result = mysql_query("select * from `pedidos`");
for ($i = 0; $i < mysql_num_fields($result); $i++) {
$ab = mysql_field_name($result,$i);
while($row = mysql_fetch_array($result)){
$new_contents= ''.$ab.''.''.$row[$i].'';
}
}
$file = 'dados.txt';
$fh = fopen($file, 'w+');
fwrite($fh, $new_contents);
fclose($fh);
$aquivoNome = 'dados.txt';
$arquivoLocal = $aquivoNome;
if (!file_exists($arquivoLocal)) {
exit;
}
$novoNome = $_GET[nome_arquivo].'.'.$_GET[tipo];
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.$novoNome.'"');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($aquivoNome));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Expires: 0');
readfile($aquivoNome);
}
?>
Vlws
Fewdox :D
Carregando comentários...