mysql - Insert data from textfile to a database table -
I want to ask some help from entering data in a database table from texfile
.... I have created a php code to execute the file on the table, but I have no luck in importing it ... can anyone know how to do this? Please help me
Current PHP code: < / P>
& lt ;? Php $ host = "localhost"; $ User = "root"; $ Pass = ""; $ Db = "clayton"; $ Connect = mysql_connect ($ host, $ user, $ pass); If (! $ Connect) die ("can not connect!"); Mysql_select_db ($ db, $ connect); $ File = fopen ("tblApplicants.txt", "r"); Whereas ($ applicant = fgets ($ file)) Include {$ sql = "TB_Applications (AIC, Name) values ('$ applicants')"; Mysql_query ($ sql); }? & Gt;
Read each row from this file, leave every second line $ i% 2 == 0 break; This "|" Explode and get another ($ line [1]) and the next object ($ line [2]), then trim it, and insert the SQL. Try to do this way
Comments
Post a Comment