php读取文件内容

读取文件内容并且写入到数据库还是一个蛮简单的事情。

$file_handle = fopen($_FILES["file"]["tmp_name"], "r");
$i=0;

while ($hh=fscanf($file_handle,"%s	%s	%s	%s	%s	%s	%s	%d	%d
")) {
    list($bookid,$class,$bookname,$press,$year,$author,$price,$number,$surplus) = $hh;
    $str="insert into booklist (bookid,class,bookname,press,year,author,price,number,surplus) value ('$bookid','$class','$bookname','$press','$year','$author','$price',$number,$surplus)";
    $ok=mysql_query($str);
//    echo $bookid.' '."<br/>";
    $i=$i+1;

//    echo $class.' '."<br/>";
//    echo $bookname.' '."<br/>";
//    echo $press.' '."<br/>";
//    echo $year.' '."<br/>";
//    echo $author.' '."<br/>";
//    echo $price.' '."<br/>";
//    echo $number.' '."<br/>";
//    echo $surplus.' '."<br/>";
}
fclose($file_handle);
原文地址:https://www.cnblogs.com/zjunet/p/4559912.html