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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -