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
Ïà¹ØÎĵµ£º
½ñÌìÈ¥XX¹«Ë¾ÃæÊÔÁË£¬¸Ð¾õºÜ²»ÀíÏë¡£ÒòΪÕâÒ»¶Îʱ¼ä¶¼ÔÚ¼ÓÉîZend Framework£¬¶¼Ã»Á·Ï°³£Óú¯ÊýºÍ·½·¨ÁË¡£
±ÊÊԻشðµÄ²»Ì«ºÃ£¬ÌرðÊÇJS²¿·Ö£¬Ò²ÊÇÐí¾Ã¶¼Ã»¸´Ï°µÄÔÒò¡£
ÉÏ»úÌâÄ¿ÊÇҪдһ¸ö·Âgoogle·ÖÒ³µÄÀ࣬µ±ÒªÈ¡ÀàËÆ9/2µÄ×î´óÕûÊý£¬È´ÔõôҲÏë²»Æðº¯ÊýceilµÄÃû×Ö£¬ÔÎÁË°ëÌì¡£
×îºó²âÊÔ³ÌÐòû´íÎ󣬵«ÊǾÍÊDz»ÄÜÕ ......
1£ºsmarty »º´æµÄÅäÖÃ
Php´úÂë
$smarty->cache_dir = "/caches/"; //»º´æĿ¼
$smarty->caching = true; //¿ªÆô»º´æ,ΪflaseµÄʱºî»º´æÎÞЧ
$smarty->cache_lifetime = 60; //»º´æʱ¼ä
2:smarty»º´æµÄʹÓúÍÇå³ý
Php´úÂë
$smarty->di ......
Ò»¡¢ ¿ª·¢³ÉÔ±
a)ÏîÄ¿Ö÷¹Ü
b)Ò³ÃæÃÀ¹¤
c)Ò³Ã濪·¢
d)·þÎñ¶Ë³ÌÐò¿ª·¢
e)ϵͳÓëÊý¾Ý¹ÜÀí
f)²âÊÔÓë°æ±¾¿ØÖÆ
¶þ¡¢ ÍøÕ¾×鿪·¢¼òÃ÷Á÷³Ì
Èý¡¢ ¿ª·¢¹¤¾ßÓë»·¾³
a) ·þÎñÆ÷ÅäÖÃ
i. WEB·þÎñÆ÷£º FreeBSD6.1+Apache2.0+PHP5.0£¬SVN°æ±¾¿ØÖÆ·þÎñ(½ö²âÊÔ»ú)¡£
ii. Êý¾Ý¿â·þÎñÆ÷£º WIN2003 server+SQL server 2000 ......
YiiÊÇÒ»¸ö¸ßÐÔÄܵÄPHP5µÄwebÓ¦ÓóÌÐò¿ª·¢¿ò¼Ü¡£Í¨¹ýÒ»¸ö¼òµ¥µÄÃüÁîÐй¤¾ß yiic ¿ÉÒÔ¿ìËÙ´´½¨Ò»¸öwebÓ¦ÓóÌÐòµÄ´úÂë¿ò¼Ü£¬¿ª·¢Õß¿ÉÒÔÔÚÉú³ÉµÄ´úÂë¿ò¼Ü»ù´¡ÉÏÌí¼ÓÒµÎñÂß¼£¬ÒÔ¿ìËÙÍê³ÉÓ¦ÓóÌÐòµÄ¿ª·¢¡£
а汾ÐÞÕýÁË´óÁ¿µÄbug£¬¶Ô³¬¹ý20ÏîµÄ¹¦ÄܽøÐÐÁ˸Ľø£»Í¨¹ýɾ³ýÎÞÓÃµÄ SQL JOIN À´ÌáÉýÁËÀÁģʽϹØϵ AR ²éѯµÄÐÔÄÜ¡£
......
ÍøÉÏÕÒµ½µÄ£º¹²ÏíÒ»ÏÂ
<?
//¡¾¾¯¸æ¡¿:δ¾Ðí¿ÉÇëÎðËæ±ãÐÞ¸Ä
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
//
// ¡¾ÎļþÃû¡¿: c_check.inc
// ¡¾× ......