Monday, 30 November 2015
Reading and printing a (.txt) file on web page in PHP & Save the data to Database
<?php
$myfile = fopen("time.txt", "r") or die("Unable to open file!");
while(!feof($myfile)) {
$x = fgets($myfile);
echo $x;
echo "<br>"; //save it to DB
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
mysql_query("insert into tbltime values('','".$x."','".$x."')",$A) or die("Error in insert query!");
mysql_close($A);
}
fclose ($myfile);
?>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment