1. Directly on the code, the key is to use
2. The code is as follows:
<?PHP#Add recommendation to English station$file=fopen(' Code.csv ', ' R '); while($data=Fgetcsv($file)) {//each time you read a row in the CSV//print_r ($data);//This is an array, to get every data, access the array subscript can$goods[] =$data; } //Var_dump ($goods); foreach($goods as $key=$value){ $id=$value[' 0 ']; //echo $id; exit (); $code=$value[' 1 ']; $area=$value[' 2 ']; $time= Time(); Echo $id; Echo $code; $area 1="Array (' title ' = ' = '$code' , ' inputtime ' = '$time' , ' style ' = ', ')";Echo $area 1; $db _connect=mysql_connect(' localhost ', ' root ', ' root ') or die("Unable to connect to the mysql!"); //Select a database to operate on mysql_select_db(' Huamei ',$db _connect); mysql_query("SET NAMES GBK"); Echo $sql 1="INSERT INTO V9_position_data (id,catid,posid,module,modelid,thumb,data,siteid,listorder,expiration,extention, Synedit) VALUES ('$id', ' one ', ' + ', ' content ', ' 13 ', ' 0 ', \ '$area 1\ ", ' 1 ', '".$id. "', ' 0 ', ' ', ' 0 ')"; //exit (); /*$rs 1=mysql_query ($sql 1); if ($rs 1>0) {echo "executed successfully"; echo "<br/>"; }else{echo "execution failed"; echo "<br/>"; } */ if(mysql_query($sql 1))//return True after insert succeeds, failure returns false Echo"Add Success";Else Echo"Add Failed"; } fclose($file);?>
Reading data in CSV format