<?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');
?>