コード例 #1
0
 * @Time:2012-5-4
 * @Version:V9.0
 */
session_start();
// 输出Excel文件头,可把user.csv换成你要的文件名
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="contact.csv"');
header('Cache-Control: max-age=0');
require '../config/config.php';
//调用数据库配置文件
require '../include/class/mysql_class.php';
/* 载入MYSQL,初始化 */
$mysql = new MYSQL($db_host, $db_user, $db_pass, $db_name);
/**获取为分组ID*/
$sqls = "select * from zy_contact_list  where  company_id=" . $_SESSION['user']['customer']->company_id . " ORDER BY contact_list_id ASC";
$contact_list_id = $mysql->select($sqls);
/**获取值*/
$group = $_POST['contact_list_id'];
/**连接数据库 用户名 密码*/
$lnk = mysql_connect($db_host, $db_user, $db_pass) or die('Not connected : ' . mysql_error());
/**连接所需要的数据库*/
mysql_select_db($db_name, $lnk) or die('Can\'t use zy-sms : ' . mysql_error());
if (!empty($group)) {
    for ($i = 0; $i < count($group); $i++) {
        $link = $group[$i];
        $links .= "or contact_list like '%[{$link}]%' ";
    }
} else {
    $link = $contact_list_id[0]->contact_list_id;
}
$sql = 'select contact_id,contact_first_name, contact_surname, contact_email, contact_mobile,contact_phone,contact_title,' . 'contact_birth_date,contact_address,contact_remark from zy_contact where contact_list like ' . "'%[{$link}]%'" . ' ' . $links . ' and company_id=' . $_SESSION['user']['customer']->company_id;