Saturday 15 March 2014

php - Mysql restore from file -



php - Mysql restore from file -

i have database table saved in txt file format of following

id | name | score | reward | result | note id | name | score | reward | result | note id | name | score | reward | result | note

i set these database mysql database table. can done using php?

what if format

|id | name | score | reward | result | note| |id | name | score | reward | result | note| |id | name | score | reward | result | note|

this help you:

$file = file('file.txt'); foreach ($file $line) { $column = explode("|", $line); $a = $column[0]; $b = $column[1]; $c = $column[2]; $d = $column[3]; $e = $column[4]; $f = $column[5]; $query = "insert table (a,b,c,d,e,f) values ('$a','$b','$c','$d','$e','$f'); mysqli_query($sql,$query); }

you'll want utilize prepared statements instead, , need alter insert depending on db connection... of course of study need alter table , table columns needs

php mysql database

No comments:

Post a Comment