My TXT file data.txt format is as follows, separated by | Two fields, one is the device number, and the other is the state
A201| is being maintained.
A202| has been completed.
A203| is being maintained.
b201| equipment has been broken, waiting for processing
。。。
Now you want to batch update MySQL database with PHP, each device number is executed
Update Shebei set content= ' TXT file in the second field ' where shebeiid= ' txt file in the first field '
How do I write this PHP code? Beginner, need code
Excel table format I will use Excel_reader, but now people give me the file format is txt, because I touch the code is not much, do not know how to get
Reply to discussion (solution)
$ar = Array_map (' Trim ', file (' Data.txt '));
foreach ($ar as $row) {
$v = Explode (' | ', $row);
$sql = "Update Shebei set content= ' $v [1] ' where shebeiid= ' $v [0] '";
Code to execute SQL instructions
}
Master Upstairs, thank you.
Look at the ... Use the
This is really too simple.