<!DOCTYPE html>
<html>
<head>
<title>
Copying of one text file to another
</title>
</head>
<body>
<!--php code-->
<?php
//copying context to 'text1.txt' to 'text2.txt';
//copy function: copy('text1.txt','text2.txt');
$f1 = fopen('text1.txt','r');
$f2 = fopen('text2.txt','w');
while(!feof($f1))
{
if(!fwrite($f2,fgets($f1)))
die("Error copying");
}
echo "Copied";
fclose($f1);
fclose($f2);
?>
</body>
</html><!DOCTYPE html>
<html>
<head>
<title>Display data from database</title>
</head>
<body>
<?php
/*Assume Database Name:'test'
Table Name:'info'
Column Name:'name','address'
*/
//connecting database
$con = mysqli_connect('localhost','root','','test') or die('Error connecting to database');
$code = 'SELECT * FROM info';
$r = mysqli_query($con,$code) or die('Error in code');
echo "<table border='1' style='border-collapse:collapse';>";
echo "<tr>";
echo "<td align='center'>Name:</td>";
echo "<td align='center'>Address:</td>";
echo "</tr>";
while($res= mysqli_fetch_array($r))
{
echo"<tr>";
echo"<td>".$res[0]."</td>";
echo"<td>".$res[1]."</td>";
echo"</tr>";
}
echo "</table>";
?>
</body>
</html>