Location: PHPKode > projects > XMasDB > xmasdb/oldexport.php
<?php
// start the session
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['basic_is_logged_in']) 
    || $_SESSION['basic_is_logged_in'] !== true) {

    // not logged in, move to login page
    header('Location: index.php');
    exit;
}

?>
<?
include 'config.php';
include 'lib/opendb.php';

$query = "SELECT name, gift FROM gifts ORDER by name";
$result = mysql_query($query) or die('Error, query failed');

$tsv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
	$tsv[]  = implode("\t", $row);
	$html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>";
}

$tsv  = implode("\r\n", $tsv);
$html = "<table>" . implode("\r\n", $html) . "</table>";

$fileName = 'gifts-to-excel.xls';
header("Content-type: application/vnd.ms-excel"); 
header("Content-Disposition: attachment; filename=$fileName");

//echo $tsv;
echo $html;

include 'lib/closedb.php';
?>
Return current item: XMasDB