当前位置: 首页>>代码示例>>PHP>>正文


PHP export_csv函数代码示例

本文整理汇总了PHP中export_csv函数的典型用法代码示例。如果您正苦于以下问题:PHP export_csv函数的具体用法?PHP export_csv怎么用?PHP export_csv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了export_csv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: users_export_controller

/**
 * Created by PhpStorm.
 * User: matedealer
 * Date: 3/23/16
 * Time: 7:29 PM
 */
function users_export_controller($type)
{
    if (isset($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}\$/", $_REQUEST['key'])) {
        $key = $_REQUEST['key'];
    } else {
        die("Missing key.");
    }
    $user = User_by_api_key($key);
    if ($user === false) {
        die("Unable to find user.");
    }
    if ($user == null) {
        die("Key invalid.");
    }
    if (!in_array('admin_user', privileges_for_user($user['UID']))) {
        die("No privilege for export users.");
    }
    if ($type == 'csv') {
        export_csv();
    } elseif ($type == 'mail') {
        export_mail();
    }
}
开发者ID:d120,项目名称:engelsystem,代码行数:29,代码来源:export_users_controller.php

示例2: db_connect

}
db_connect($db_server, $db_name, $db_user, $db_pass);
if ($db_charset && 'mysql' == $db_driver) {
    db_exe("SET NAMES {$db_charset}");
}
if (isset($_GET['dump_all']) && 1 == $_GET['dump_all']) {
    dump_all($data = false);
}
if (isset($_GET['dump_all']) && 2 == $_GET['dump_all']) {
    dump_all($data = true);
}
if (isset($_GET['dump_table']) && $_GET['dump_table']) {
    dump_table($_GET['dump_table']);
}
if (isset($_GET['export']) && 'csv' == $_GET['export']) {
    export_csv(base64_decode($_GET['query']), $_GET['separator']);
}
if (isset($_POST['sqlfile']) && $_POST['sqlfile']) {
    $files = sql_files_assoc();
    if (!isset($files[$_POST['sqlfile']])) {
        exit('File not found. md5 = ' . $_POST['sqlfile']);
    }
    $sqlfile = $files[$_POST['sqlfile']];
    layout();
    echo '<div>Importing: <b>' . $sqlfile . '</b> (' . size(filesize($sqlfile)) . ')</div>';
    echo '<div>Database: <b>' . $db_name . '</b></div>';
    flush();
    import($sqlfile, post('ignore_errors'), post('transaction'), post('force_myisam'), post('query_start', 'int'));
    exit;
}
if (isset($_POST['drop_table']) && $_POST['drop_table']) {
开发者ID:rubencamargogomez,项目名称:custom_properties,代码行数:31,代码来源:dbkiss.php

示例3: switch

 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
// Get an exported representation of something (at the moment, only a project)
// Call as: get_export.php?entity=project&id=1&format=planner
require_once "../alloc.php";
if (isset($_GET["id"]) && isset($_GET["entity"])) {
    switch ($_GET["entity"]) {
        case "project":
            switch ($_GET["format"]) {
                case "planner":
                    header('Content-Type: application/xml');
                    header('Content-Disposition: attachment; filename="allocProject.planner"');
                    echo export_gnome_planner(intval($_GET["id"]));
                    break;
                case "csv":
                    header('Content-Type: text/plain');
                    header('Content-Disposition: attachment; filename="allocProject.csv"');
                    echo export_csv(intval($_GET["id"]));
            }
            break;
    }
}
开发者ID:cjbayliss,项目名称:alloc,代码行数:31,代码来源:get_export.php

示例4: strftime

    case "weight_chart":
        $sth = $conn->prepare("SELECT strftime('%s',date)*1000 AS datetime, hiveweight, hiverawweight FROM allhivedata WHERE date > datetime('now','{$sqlperiod}') ORDER BY datetime");
        $sth->execute();
        $result = $sth->fetchAll(PDO::FETCH_ASSOC);
        foreach ($result as $r) {
            $out[] = array((double) $r['datetime'], (double) $r['hiveweight']);
        }
        break;
    case "weight_data":
        $sth = $conn->prepare("SELECT hiveid, date, hiveweight, hiverawweight FROM allhivedata WHERE date > datetime('now','{$sqlperiod}') ORDER BY date");
        $sth->execute();
        break;
}
switch ($output) {
    case "csv":
        export_csv($sth, $type, $period);
        break;
    case "json":
        export_json($sth);
        break;
    case "highcharts":
        export_highcharts($out);
        break;
}
#echo "Period is $sqlperiod";
#echo "Type is $type";
// Get Weather/Hive Data First - from a DB view, this may be very slow
function export_highcharts($out)
{
    //?type=temp&period=month&output=highcharts'
    // Convert time to Unix EPOCH, output one value only.
开发者ID:gitter-badger,项目名称:HiveControl,代码行数:31,代码来源:datajob.php

示例5: export_fixed_width

 */
include "../functions/functions.export.php";
if (isset($_GET['data'])) {
    export_fixed_width(intval($_GET['data']));
    exit;
}
if (isset($_GET['ddi'])) {
    export_ddi(intval($_GET['ddi']));
    exit;
}
if (isset($_GET['csv'])) {
    export_csv(intval($_GET['csv']));
    exit;
}
if (isset($_GET['csvl'])) {
    export_csv(intval($_GET['csvl']), true, true);
    exit;
}
if (isset($_GET['pspp'])) {
    export_pspp(intval($_GET['pspp']));
    exit;
}
if (isset($_GET['psppn'])) {
    export_pspp(intval($_GET['psppn']), false);
    exit;
}
xhtml_head(T_("Export Data"), true, array("../css/table.css"), array("../js/display.js"));
$data_id = 0;
if (isset($_GET['data_id'])) {
    $data_id = intval($_GET['data_id']);
}
开发者ID:ddrmoscow,项目名称:queXC,代码行数:31,代码来源:export.php

示例6: array

$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace'));
Display::display_header($nameTools);
// Database Table Definitions
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_track_exercice = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
/*
 	MAIN CODE
*/
$sql_course = "SELECT title, code, id FROM {$tbl_course} as course ORDER BY title ASC";
$result_course = Database::query($sql_course);
if (Database::num_rows($result_course) > 0) {
    if (isset($_POST['export'])) {
        $export_result = export_csv($header, $data, 'test.csv');
        // TODO: There is no data for exporting yet.
        Display::display_error_message($export_result);
    }
    echo '<table class="data_table"><tr><th>' . get_lang('Course') . '</th><th>' . get_lang('TempsFrequentation') . '</th><th>' . get_lang('Progression') . '</th><th>' . get_lang('MoyenneTest') . '</th></tr>';
    $header = array(get_lang('Course', ''), get_lang('TempsFrequentation', ''), get_lang('Progression', ''), get_lang('MoyenneTest', ''));
    while ($a_course = Database::fetch_array($result_course)) {
        // TODO: This query is to be checked, there are no HotPotatoes tests results.
        $sql_moy_test = "SELECT exe_result,exe_weighting\n\t\t\tFROM {$tbl_track_exercice}\n\t\t\tWHERE c_id = " . $a_course['id'];
        $result_moy_test = Database::query($sql_moy_test);
        $result = 0;
        $weighting = 0;
        while ($moy_test = Database::fetch_array($result_moy_test)) {
            $result = $result + $moy_test['exe_result'];
            $weighting = $weighting + $moy_test['exe_weighting'];
        }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:31,代码来源:progression.php

示例7: _wpr_export

function _wpr_export()
{
    $nid = $_POST['newsletter'];
    export_csv($nid);
    exit;
}
开发者ID:anirut,项目名称:wp-autoresponder,代码行数:6,代码来源:importexport.php

示例8: die

if (!defined('SYSTEM_ROOT')) {
    die('Insufficient Permissions');
}
function export_csv($filename, $data)
{
    header("Content-type:text/csv");
    header("Content-Disposition:attachment;filename=" . $filename);
    header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
    header('Expires:0');
    header('Pragma:public');
    echo $data;
}
if (isset($_REQUEST['e'])) {
    global $m;
    $m->query('TRUNCATE TABLE `' . DB_NAME . '`.`' . DB_PREFIX . 'fyy_errorlog`');
    Redirect(SYSTEM_URL . 'index.php?mod=admin:tools&ok');
} elseif (isset($_REQUEST['d'])) {
    global $m;
    $csv = $m->query('SELECT * FROM `' . DB_NAME . '`.`' . DB_PREFIX . 'fyy_errorlog` ORDER BY `time`');
    $str = "错误信息,时间,种类,路径,行数\n";
    $str = iconv('utf-8', 'gb2312', $str);
    while ($row = $m->fetch_array($csv)) {
        $row['error'] = iconv('utf-8', 'gb2312', $row['error']);
        $row['type'] = iconv('utf-8', 'gb2312', $row['type']);
        $row['file'] = iconv('utf-8', 'gb2312', $row['file']);
        $row['line'] = iconv('utf-8', 'gb2312', $row['line']);
        $str .= $row['error'] . "," . $row['time'] . "," . $row['type'] . "," . $row['file'] . "," . $row['line'] . "\n";
    }
    $filename = '错误信息' . date('Ymd') . '.csv';
    export_csv($filename, $str);
}
开发者ID:chajianku,项目名称:fyy_errorlog,代码行数:31,代码来源:fyy_errorlog_private.php

示例9: elseif

            //print _T('None', 'msc')." ".$verb[0]." ";
        } elseif ($ss[0] == '1') {
            print _T('One', 'msc') . " " . $verb[0] . " ";
        } else {
            print $ss[0] . " " . $verb[1] . " ";
        }
        if ($ss[0] != '0') {
            print $sl[1];
        }
        if (count($sl) == 4 and $ss[0] != '0') {
            print " " . sprintf($sl[3], $status[$l[0]][$sl[2]][0]);
        }
        if ($ss[0] == 0) {
            //print "</td><td><img src='modules/msc/graph/nocsv.png' alt='no csv export possible'/></td></tr>";
        } else {
            print "</td>" . export_csv($cmd_id, $_GET['bundle_id'], $sl[0]) . "</tr>";
        }
    }
}
/*
 *  bundle treatment:
 *  -----------------
 *
 *  machines can be stored in more than one status (one package can be success, and another in fail state)
 *
 *  If one package is failed, bundle is in fail status
 *  If no failed, but one running package, bundle is in running status
 *  For package paused => running status
 *  For package stopped => failed status
 */
if (strlen($_GET['bundle_id']) and !isset($_GET['tab'])) {
开发者ID:neoclust,项目名称:mmc,代码行数:31,代码来源:msctabsstatus.php

示例10: header

if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
    header("Location: ../../login.php");
}
$ini_array = parse_ini_file("../../config/cmdb.conf");
$dbhost = $ini_array['db_host'];
$dbport = $ini_array['db_port'];
$dbuser = $ini_array['db_user'];
$dbpass = $ini_array['db_pass'];
$dbname = $ini_array['db_name'];
$conn = mysql_connect("{$dbhost}:{$dbport}", $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
include_once '../../classes/Contact.php';
$file_name = trim($_GET['report_name']) . ".csv";
header("Content-type:text/octect-stream");
header("Content-Disposition:attachment;filename=\"{$file_name}\"");
$csv_data = export_csv();
print $csv_data;
function export_csv()
{
    if (isset($_GET['report_name']) && $_GET['report_name'] != '') {
        $name = $_GET['report_name'];
    } else {
        return "<b>Sorry invalid report name " . $_GET['report_name'] . "</b>";
    }
    $query = "select accounting_reports.id, accounting_reports.profile_id, accounting_reports.report_name, \n\t\t\taccounting_reports.date1, accounting_reports.date2, \n\t\t\taccounting_reports.avg_in, accounting_reports.avg_out, \n\t\t\taccounting_reports.max_in, accounting_reports.max_out,95_in as in95,\n\t\t\taccounting_reports.95_out as out95 , accounting_reports.tot_in, accounting_reports.tot_out,\n\t\t\taccounting_reports.sample_date1,   accounting_reports.sample_date2, \n\t\t\taccounting_reports.traffic_cap, accounting_profiles.client_id\n\t\t\tfrom \n\t\t\taccounting_reports, accounting_profiles where report_name = '{$name}'\n\t\t\tAND accounting_profiles.profile_id =  accounting_reports.profile_id";
    $result = mysql_query($query);
    if (!$result) {
        return "failed to execute query {$query}<br>";
    }
    $heading = array("Client", "Accounting Profile", "Report Name", "Start date", "End date", "Average In (b/s)", "Average out (b/s)", "Max In (b/s)", "Max out (b/s)", "95% In (b/s)", "95% out (b/s)", "95% Billing (b/s)", "95% Billing (Mb/s)", "Committed Traffic (b/s)", "Commitment Status", "Total In (Bytes)", "Total out (Bytes)", "First Sample date", "Last Sample date");
    $content = implode(",", $heading);
开发者ID:precurse,项目名称:netharbour,代码行数:31,代码来源:export_csv.php

示例11: foreach

        }
        $data .= "\n";
        foreach ($items as $item) {
            foreach ($data_field as $key => $value) {
                $item[$key] = str_replace("&nbsp;", " ", $item[$key]);
                $item[$key] = htmlspecialchars_decode($item[$key]);
                //$item[$key] = str_replace(',', ' ', $item[$key]);
                $item[$key] = preg_replace("/[\r\n]+/", ' ', $item[$key]);
                $data .= '"' . $item[$key] . '"' . ',';
            }
            $data .= "\n";
        }
        return $data;
    } else {
        return 'no data';
    }
}
if ($_GET['active'] == 'true') {
    $user_data = get_data($activity_id, true);
} else {
    $user_data = get_data($activity_id, false);
}
$user_data = mb_convert_encoding($user_data, 'GBK', 'UTF-8');
if ($_GET['active'] == 'true') {
    $filename = 'actived_user-' . date('Ymd') . '.csv';
} else {
    $filename = 'processing_user-' . date('Ymd') . '.csv';
}
$filename = iconv('UTF-8', 'GBK', $filename);
export_csv($filename, $user_data);
开发者ID:WSKINGS,项目名称:chat_tickets,代码行数:30,代码来源:manage_export.php

示例12: export_csv

 */
include "../config.inc.php";
/**
 * XHTML functions
 */
include "../functions/functions.xhtml.php";
/**
 * DB functions
 */
include "../db.inc.php";
/**
 * Export functions
 */
include "../functions/functions.export.php";
if (isset($_GET['download']) && isset($_GET['data_id']) && isset($_GET['code_column']) && isset($_GET['text_column'])) {
    export_csv(intval($_GET['data_id']), true, false, false, array(intval($_GET['code_column']), intval($_GET['text_column'])), false);
    exit;
}
xhtml_head(T_("Export code keyword correspondence"), true, array("../css/table.css"), array("../js/display.js"));
$data_id = 0;
if (isset($_GET['data_id'])) {
    $data_id = intval($_GET['data_id']);
}
//Select a data file to export data from
$sql = "SELECT data_id as value,description, CASE WHEN data_id = '{$data_id}' THEN 'selected=\\'selected\\'' ELSE '' END AS selected\r\n\tFROM data";
print "<div>" . T_("Select data file: ");
display_chooser($db->GetAll($sql), 'data_id', 'data_id');
print "</div>";
if ($data_id != 0) {
    $code_column = 0;
    if (isset($_GET['code_column'])) {
开发者ID:ddrmoscow,项目名称:queXC,代码行数:31,代码来源:exportkeywords.php

示例13: get_main_table

// Database Table Definitions
$tbl_course 		= Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_user 			= Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session 		= Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);

/*
 	MAIN CODE
*/
$sql_course = "SELECT title,code FROM $tbl_course as course ORDER BY title ASC";
$result_course = Database::query($sql_course);

if (Database::num_rows($result_course) > 0) {
	if (isset($_POST['export'])) {
		$export_result = export_csv($header, $data, 'test.csv'); // TODO: There is no data for exporting yet.
		Display :: display_error_message($export_result);
	}
	echo '<table class="data_table"><tr><th>'.get_lang('Course').'</th><th>'.get_lang('TempsFrequentation').'</th><th>'.get_lang('Progression').'</th><th>'.get_lang('MoyenneTest').'</th></tr>';
	$header = array(get_lang('Course', ''), get_lang('TempsFrequentation', ''), get_lang('Progression', ''), get_lang('MoyenneTest', ''));
	while ($a_course = Database::fetch_array($result_course)) {
		// TODO: This query is to be checked, there are no HotPotatoes tests results.
		$sql_moy_test = "SELECT exe_result,exe_weighting
			FROM $tbl_track_exercice
			WHERE exe_cours_id = '".$a_course['code']."'";
		$result_moy_test = Database::query($sql_moy_test);
		$result = 0;
		$weighting = 0;
		while ($moy_test = Database::fetch_array($result_moy_test)) {
			$result = $result + $moy_test['exe_result'];
			$weighting = $weighting + $moy_test['exe_weighting'];
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:progression.php

示例14: mysqli

<?php

$mysqli = new mysqli("localhost", "skostyukovich", "mansion471", "u95648_instat");
if (mysqli_connect_errno()) {
    echo "Подключение невозможно: " . mysqli_connect_error();
}
$mysqli->set_charset('utf8');
function export_csv($table, $afields, $filename, $delim = ',', $enclosed = '"', $escaped = '\\', $lineend = '\\r\\n')
{
    $q_export = "SELECT " . implode(',', $afields) . "   INTO OUTFILE '" . $_SERVER['DOCUMENT_ROOT'] . $filename . "' " . "FIELDS TERMINATED BY '" . $delim . "' ENCLOSED BY '" . $enclosed . "' " . "    ESCAPED BY '" . $escaped . "' " . "LINES TERMINATED BY '" . $lineend . "' " . "FROM " . $table;
    // Если файл существует, при экспорте будет выдана ошибка
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . $filename)) {
        unlink($_SERVER['DOCUMENT_ROOT'] . $filename);
    }
    return mysql_query($q_export);
}
$table = "request";
$afields = array('authorization', 'source', 'goal');
$filename = "file3.csv";
var_dump(export_csv($table, $afields, $filename, $delim = ',', $enclosed = '"', $escaped = '\\', $lineend = '\\r\\n'));
开发者ID:SKostyukovich,项目名称:instat,代码行数:20,代码来源:export_csv.php

示例15: exit

        exit("Ошибка " . mysql_error());
    }
    if (mysql_num_rows($kar)) {
        $fd = fopen('../files/' . $file_name, "w");
        $header = array('id', 'iditem', 'name', 'space1', 'space2', 'price', 'manufected', 'category', 'keywords', 'image', 'vip', 'levl', 'public', 'chpu', 'h1', 'title', 'description', 'rating', 'share', 'view');
        fputcsv($fd, $header, $delimiter = ';');
        while ($kart = mysql_fetch_array($kar)) {
            $query = "SELECT name FROM manufekted WHERE id='" . $kart['manufekted'] . "'";
            $result = mysql_query($query);
            $res = mysql_fetch_row($result);
            $query = "SELECT name FROM catecory WHERE id='" . $kart['category'] . "'";
            $result = mysql_query($query);
            $res1 = mysql_fetch_row($result);
            // перекодировка и запись в файл для того что бы читалось в exel
            $order = mb_convert_encoding(str_replace('"', ' ', $kart['id']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding($kart['iditem'], "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['name']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding('', "Windows-1251", "UTF-8") . ";" . mb_convert_encoding('', "Windows-1251", "UTF-8") . ";" . mb_convert_encoding($kart['price'], "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $res[0]), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $res1[0]), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['keywords']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['image']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['vip']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['levl']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['publick']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['chpu']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['h1']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['title']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['description']), "Windows-1251", "UTF-8") . ";" . mb_convert_encoding(str_replace($search, ' ', $kart['rating']), "Windows-1251", "UTF-8") . ";" . str_replace($search, ' ', $kart['share']) . ";" . str_replace($search, ' ', $kart['view']) . "\r\n";
            fwrite($fd, $order);
        }
        fclose($fd);
    }
    return 1;
}
$db = mysql_connect("localhost", "garantma_user", "crKAyqBMMaEq");
mysql_select_db("garantma_db", $db);
//$db=mysql_connect("localhost", "root", "");
//mysql_select_db("garantmarket", $db);
$afields[] = 'name';
$afields[] = 'id';
$f_name = 'garant-' . date('dmY_G.i') . '.csv';
if (export_csv($f_name)) {
    echo $f_name;
}
开发者ID:pioytazsko,项目名称:garantmarket,代码行数:31,代码来源:expport.php


注:本文中的export_csv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。