insert.php
<html>
<body>
<form action="insert_pro.php" method="post">
Name :<br />
<input type="text" name="nm" />
<br /><br />
Salary :<br />
<input type="text" name="sal" />
<br /><br />
<input type="submit" value="Insert">
</form>
</body>
</html>
insert_pro.php
<?php
$nm=$_POST['nm'];
$sal=$_POST['sal'];
$link=mysql_connect("localhost","root","") or die("can't connect");
mysql_select_db("employee",$link) or die("Wrong Database");
$q="insert into emp
(nm,salary)
values('$nm',$sal)";
mysql_query($q,$link) or die($q);
header("location:view.php");
?>
view.php
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
<th>Salary</th>
<th>Delete</th>
</tr>
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("employee",$link);
$q="select * from emp";
$res=mysql_query($q,$link);
while($row=mysql_fetch_array($res))
{
echo '<tr align="center">';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['nm'].'</td>';
echo '<td>'.$row['salary'].'</td>';
echo '<td><a href="delete_pro.php?no='.$row['id'].'">X</a></td>';
echo '</tr>';
}
?>
</table>
</body>
</html>
delete_pro.php
<?php
$id=$_GET['no'];
$link=mysql_connect("localhost","root","");
mysql_select_db("employee",$link);
$q="delete from emp where id=$id";
mysql_query($q,$link);
header("location:view.php");
?>
<html>
<body>
<form action="insert_pro.php" method="post">
Name :<br />
<input type="text" name="nm" />
<br /><br />
Salary :<br />
<input type="text" name="sal" />
<br /><br />
<input type="submit" value="Insert">
</form>
</body>
</html>
insert_pro.php
<?php
$nm=$_POST['nm'];
$sal=$_POST['sal'];
$link=mysql_connect("localhost","root","") or die("can't connect");
mysql_select_db("employee",$link) or die("Wrong Database");
$q="insert into emp
(nm,salary)
values('$nm',$sal)";
mysql_query($q,$link) or die($q);
header("location:view.php");
?>
view.php
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
<th>Salary</th>
<th>Delete</th>
</tr>
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("employee",$link);
$q="select * from emp";
$res=mysql_query($q,$link);
while($row=mysql_fetch_array($res))
{
echo '<tr align="center">';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['nm'].'</td>';
echo '<td>'.$row['salary'].'</td>';
echo '<td><a href="delete_pro.php?no='.$row['id'].'">X</a></td>';
echo '</tr>';
}
?>
</table>
</body>
</html>
delete_pro.php
<?php
$id=$_GET['no'];
$link=mysql_connect("localhost","root","");
mysql_select_db("employee",$link);
$q="delete from emp where id=$id";
mysql_query($q,$link);
header("location:view.php");
?>