php excel导入mysql_PHP将Excel内容导入mysql数据库
//exp.php 用于導出
include_once 'conn.php';
$savename = date("YmjHis");
mysql_query("Set Names 'gbk'");
$file_type = "vnd.ms-excel";
$file_ending = "xls";
header("Content-Type: application/$file_type;charset=big5");
header("Content-Disposition: p_w_upload; filename=".$savename.".$file_ending");
header("Pragma: no-cache");
$sql = "Select * from zhbyz_2011 WHERE riq>='$_GET[ac]' and riq<='$_GET[bc]' ORDER BY `id` DESC";
$result=mysql_query($sql);
#print_r($sql);
echo("$title\n");
$sep = "\t";
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
$i = 0;
while($row = mysql_fetch_row($result)) {
$schema_insert = "";
for($j=0; $j
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
$i++;
}
return (true);
?>
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的php excel导入mysql_PHP将Excel内容导入mysql数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 光纤色散是什么?如何色散补偿?
- 下一篇: php期末考卷,php试卷B高质量含答案