tabel-van-database-exporteren-naar-xls
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// PHP Errors tonen
error_reporting(E_ALL);
ini_set("display_errors", 1);
// Database
include("_config.inc.php");
$tabel = "gebruikers";
$qXLS = "SELECT * FROM ".$tabel;
$rXLS = mysql_query($qXLS);
// Gewoon.. omdat het kan.
$output = '';
$velden = mysql_list_fields("houtenladen",$tabel);
$kolommen = mysql_num_fields($velden);
// Veldnamen
for ($i = 0; $i < $kolommen; $i++)
{
$l= mysql_field_name($velden, $i);
$output .= $l."\t";
}
$output .= "\n";
// DB gegevens
while ($l = mysql_fetch_array($rXLS))
{
$total = count($l);
for ($i = 0; $i < $kolommen; $i++)
{
$output .= $l[$i]."\t";
}
$output .= "\n";
}
// In xls stoppen
$f = fopen ('export.xls','w');
fputs($f, $output);
fclose($f);
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="Database.xls"');
readfile('export.xls');
?>
// PHP Errors tonen
error_reporting(E_ALL);
ini_set("display_errors", 1);
// Database
include("_config.inc.php");
$tabel = "gebruikers";
$qXLS = "SELECT * FROM ".$tabel;
$rXLS = mysql_query($qXLS);
// Gewoon.. omdat het kan.
$output = '';
$velden = mysql_list_fields("houtenladen",$tabel);
$kolommen = mysql_num_fields($velden);
// Veldnamen
for ($i = 0; $i < $kolommen; $i++)
{
$l= mysql_field_name($velden, $i);
$output .= $l."\t";
}
$output .= "\n";
// DB gegevens
while ($l = mysql_fetch_array($rXLS))
{
$total = count($l);
for ($i = 0; $i < $kolommen; $i++)
{
$output .= $l[$i]."\t";
}
$output .= "\n";
}
// In xls stoppen
$f = fopen ('export.xls','w');
fputs($f, $output);
fclose($f);
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="Database.xls"');
readfile('export.xls');
?>