<?php
include("includes/config.php");
if ($_POST['frmCsv']) {
$strSelect = doSelectCsv();
header( 'Content-Type: text/csv' );
header( 'Content-Disposition: attachment;filename=export.csv' );
$strRow = mysql_fetch_assoc( $strSelect );
printArray($strRow);
if ( $strRow ) {
outputcsv( array_keys( $strRow ) );
}
while ( $strRow ) {
outputcsv( $strRow );
}
}
function doSelectCsv()
{
$strSql = "SELECT * FROM tbl_member";
$strResult = SelectQry($strSql);
}
function outputcsv( $fields )
{
$separator = '';
foreach ( $fields as $field ) {
echo $separator . $field;
$separator = ',';
}
}
?>
This is my code to export a csv file from the database. but it could not select the datas. select query did not works correctly. please help me.