当前位置:Gxlcms > 数据库问题 > 将文件写进数据库的方法

将文件写进数据库的方法

时间:2021-07-01 10:21:17 帮助过:24人阅读

header("Content-Type:text/html;charset=utf-8"); //1.读取文件到数组 $file = file(‘tianqi.txt‘); //print_r($file); //2.计算数组长度 $count = count($file); //3.导入数据到数据库 mysql_connect(‘localhost‘,‘root‘,‘‘); mysql_query(‘use tianqi‘); mysql_query(‘set names utf8‘); // for($i=0;$i<$count;$i++){ $data = explode(‘=‘,$file[$i]); $code = $data[0]; $name = $data[1]; //组装sql语句 $sql = "insert into city values(null,‘$code‘,‘$name‘)"; mysql_query($sql); } mysql_close();

 

将文件写进数据库的方法

标签:file   oca   数据   htm   exp   name   xpl   字符   操作   

人气教程排行