php - insert data from file to table with seperator than put it into database -
i have text file in written in style there data:
floran / marielle
retrieve separated ;
, store them in database (sql server)
facts example table contains firstname (varchar) , name (varchar) not know if have store information in variable or table or first ? thank in advance help!
// read file $data $data = file_get_contents('names.txt'); // create array splitting @ every / $data = explode('/',$data); // create sql statement insert database $max = count($data); $sql = ''; ($i = 0; $i < $max; $i+=2) $sql .= '("' . trim($data[$i]) . '","' . trim($data[$i+1]) . '"),'; $sql = 'insert tablename (firstname,name) values ' .trim($sql,','); // add code inserting db
Comments
Post a Comment