phpÊý¾Ýµ¼Èëµ¼³öÖ®excel(csvÎļþ)
ÒýÓõØÖ·£º
http://blog.csdn.net/conan_s/archive/2008/01/04/2025495.aspx
ÓÐʱд³ÌÐòʱºǫ́ҪÇó°Ñ´óÁ¿Êý¾Ýµ¼ÈëÊý¾Ý¿âÖУ¬±ÈÈ翼ÊԳɼ¨¡¢µç»°²¾µÈÒ»°ã¶¼ÊÇ´æ·ÅÔÚexcelÖеÄÊý¾Ý£¬ÕâʱÎÒÃÇ¿É°Ñexcelµ¼³ö³ÉcsvÎļþ£¬È»ºóͨ¹ýÒÔϳÌÐò¼´¿ÉÅúÁ¿µ¼ÈëÊý¾Ýµ½Êý¾Ý¿âÖÐ
ÉÏ´«cvs²¢µ¼Èëµ½Êý¾Ý¿âÖУ¬²âÊԳɹ¦£¨²¿·Ö´úÂë²»¹æ·¶£¬ÈçPHP_SELFÄÇÀïÒª¸Äд³É
$_SERVER["PHP_SELF"] £©
PHP´úÂë
<?php
$fname = $_FILES['MyFile']['name'];
$do = copy($_FILES['MyFile']['tmp_name'],$fname);
if ($do)
{
echo"µ¼ÈëÊý¾Ý³É¹¦
";
} else {
echo "";
}
?>
<form ENCTYPE="multipart/form-data" ACTION="<?php echo"".$PHP_SELF.""; ?>" METHOD="POST">
µ¼ÈëCVSÊý¾Ý <input NAME="MyFile" TYPE="file"> <input VALUE="Ìá½»" TYPE="submit">
</form>
<?
error_reporting(0);
//µ¼ÈëCSV¸ñʽµÄÎļþ
$connect=mysql_connect("localhost","a0530093319","123456") or die("could not connect to database");
mysql_select_db("a0530093319",$connect) or die (mysql_error());
$fname = $_FILES['MyFile']['name'];
$handle=fopen("$fname","r");
while($data=fgetcsv($handle,10000,","))
{
$q="insert into test (code,name,date) values ('$data[0]','$data[1]','$data[2]')";
mysql_query($q) or die (mysql_error());
}
fclose($handle);
?>
ÓÃphp½«Êý¾Ý¿âµ¼³ö³Éexcel£¬²âÊÔÍêÈ«³É¹¦
PHP´úÂë
<?php
$DB_Server = "localhost";
$DB_Username = "a0530093319";
$DB_Password = "123456";
$DB_DBName = "a0530093319";
$DB_TBLName = "member";
$savename = date("YmjHis");
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
or die("Couldn't connect.");
mysql_query("Set Names 'gb2312'");
$file_type = "vnd.ms-excel";
$file_ending = "xls";
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=".$savename.".$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
$now_date = date("Y-m-j H:i:s");
$title = "Êý¾Ý¿âÃû:$DB_DBName,Êý¾Ý±í:$DB_TBLName,±¸·ÝÈÕÆÚ:$now_date";
$sql = "Select * from $DB_TBLName";
$ALT_Db = @mysql_select_db($DB_DBName, $Connect)
or di
Ïà¹ØÎĵµ£º
LinuxÅäÖÃAPACHE2.2.4 + PHP5.2.1 + MYSQL5.0.37 + GD¿â
µÚÒ»²½£º°²×°RedFlag Linux5.0
°²×°ÏµÍ³Ê±ÇëÎñ±Ø°²×°¿ª·¢¹¤¾ß°üºÍKDE¿ª·¢¹¤¾ß°ü£¬WWW·þÎñÆ÷ºÍSQL·þÎñÆ÷²»Òª°²×°£¬·ñÔò¿ÉÄÜ»á³öÏÖδ֪µÄ´íÎó¡£
µÚ¶þ²½£ºÈ·¶¨linuxϵͳÊÇ·ñ°²×°gcc±àÒëÆ÷
Ê×ÏÈ,GCCÒªÓÐ,²»È»Ê²Ã´¶¼²»ÄÜ×ö.¿ÉÒÔÓÃgcc -vÀ´²é¿´ÊÇ·ñ°²×°ÁËGCC,
#gcc - ......
ÆäʵÕâƪÎÄÕÂÒ²²»ÄÜËã×÷ÊÇÔ´´£¬Ö»ÊÇÔÚÔ×÷ÕߵĻù´¡ÉÏÐ޸ĵıȽ϶࣬¼¸ºõÖØдÁËÒ»±é¡£
<?php
/**
*ÔÚÔ×÷ÕߵĻù´¡ÉÏÐ޸ĵģ¬ºÇºÇ£¬²»¹ýÍü¼ÇÁËÔ×÷ÕßÊÇËÁË£¬
*Èç¹ûÔ×÷Õß¿´µ½µÄ»°£¬¸øÎÒÒ»¸öÌáʾ£¬o(∩_∩)o...
*ÎÒµÄblog:http://etongchina.blogcn.com
*ÎÒµÄÓÊÏä:etongchina@gmail.com
**/
fu ......
ºÜ¾ÃǰЩµÄһЩÎÄÕ£¬ÄÇʱºò¼¼Êõ»¹ÔÚ³õ¼¶½×¶Î£¬ÔÚÏÖÔÚ¿´À´´úÂë¹»Àõģ¬µ«ÊÇÈË×ÜÊÇÒ»²½²½×ßÉÏÀ´µÄ£¬Ï£ÍûÄܸø³õѧÕßÒ»µã¹ÄÀøÁË£¡
<?php
/*********************************************************
filename£ºmulti.php
describe£º ÏÔʾ¶àÓÚÒ»Ò³µÄÁ´½Ó
function£º·ÖÒ³ÏÔʾģ¿é
auth ......
½ñÌìÈ¥XX¹«Ë¾ÃæÊÔÁË£¬¸Ð¾õºÜ²»ÀíÏë¡£ÒòΪÕâÒ»¶Îʱ¼ä¶¼ÔÚ¼ÓÉîZend Framework£¬¶¼Ã»Á·Ï°³£Óú¯ÊýºÍ·½·¨ÁË¡£
±ÊÊԻشðµÄ²»Ì«ºÃ£¬ÌرðÊÇJS²¿·Ö£¬Ò²ÊÇÐí¾Ã¶¼Ã»¸´Ï°µÄÔÒò¡£
ÉÏ»úÌâÄ¿ÊÇҪдһ¸ö·Âgoogle·ÖÒ³µÄÀ࣬µ±ÒªÈ¡ÀàËÆ9/2µÄ×î´óÕûÊý£¬È´ÔõôҲÏë²»Æðº¯ÊýceilµÄÃû×Ö£¬ÔÎÁË°ëÌì¡£
×îºó²âÊÔ³ÌÐòû´íÎ󣬵«ÊǾÍÊDz»ÄÜÕ ......
//±éÀúĿ¼¼°Îļþ
function get_all_files( $path )
{
$list = array();
foreach( glob( $path . '/*') as $item )
{
& ......