18. Write a PHP program to implement Create,
Read, Update and Display operations on
Employee table with attributes(empno,
empname, date_of_join, address, salary). (Use Radio Buttons).
Html file :
<slip_18.html>
<html>
<body>
<form
action="slip_18.php" method="get">
<center> <h2> Enployee Details :</h2> <br>
<table>
<tr> <td><input type=radio name=r
value="1"></td>
<td><b>Create Employee Table:</b></td> </tr>
<tr> <td><input type=radio name=r
value="2"></td>
<td><b> Read/Insert Values :</b></td> </tr>
<tr> <td><input type=radio name=r
value="3"></td>
<td><b>Update Values :</b></td> </tr>
<tr> <td><input type=radio name=r
value="4"></td> <td><b>Display
:</b></td>
</tr>
</table>
<br> <input type=submit value=Submit
name=submit>
</center>
</form>
</body>
</html>
Php file :
(slip_18.php)
<?php
$r=$_GET['r'];
$con =
mysql_connect("localhost","root","");
$d =
mysql_select_db("bca_programs",$con);
if($r==1)
{
$q=mysql_query("create table
emp_slip_18(empno int,ename varchar(10),date_of_join date,salary int,address
varchar(20))");
echo "<center><b><h2>
Table Created Successfully.....!!!</h2><b></center>";
}
else
if($r==2)
{
header("location:slip_18_insert.html");
}
/*$q2=mysql_query("insert into
emp_slip_18 values($a_no,'$a_name','$d_join',$a_sal,'$a_add')");
echo "<center><b><h2>
Values Inserted Successfully.....!!!</h2><b></center>";
*/
else
if($r==3)
{
header("location:slip_18update.html");
}
else
if($r==4)
{
$q4=mysql_query("select
*from emp_slip_18");
echo
"<center>";
echo
"<table border=1 width=30% height=20%>";
echo
"<h2><tr><td><b> Emp No </b></td><td>
<b>Employee Name<b> </td><td> <b>Date
Of Joining <b></td><td> <b>Salary <b></td><td>
<b>Address<b> </td></tr></h2>";
while($row=mysql_fetch_array($q4))
{
echo
"<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[4]."</td></tr>";
}
echo
"</table>";
echo
"</center>";
}
?>
<slip_18_insert.html>
<html>
<body>
<form
action="slip_18_insert.php" method="get">
<center> <h2>Enter Enployee Details :</h2> <br>
<table>
<tr> <td>Enter Employee no :</td><td><input
type=text name=a_no> </td> </tr>
<tr> <td>Enter Employee name :</td><td><input
type=text name=a_name></td>
</tr>
<tr> <td>Enter Date Of Join :</td><td><input
type=text name=d_join></td>
</tr>
<tr> <td>Enter Salary :</td><td><input
type=text name=a_sal></td>
</tr>
<tr> <td>Enter Address :</td><td><input
type=text name=a_add></td>
</tr>
<tr>
<td><input type=submit value=Show name=submit></td> </tr>
</table>
</center>
</form>
</body>
</html>
(slip_18_insert.html)
<html>
<body>
<form
action="slip_18_insert.php" method="get">
<center> <h2>Enter Enployee Details :</h2> <br>
<table>
<tr> <td>Enter Employee no :</td><td><input
type=text name=a_no> </td> </tr>
<tr> <td>Enter Employee name :</td><td><input
type=text name=a_name></td>
</tr>
<tr> <td>Enter Date Of Join :</td><td><input
type=text name=d_join></td>
</tr>
<tr> <td>Enter Salary :</td><td><input
type=text name=a_sal></td>
</tr>
<tr> <td>Enter Address :</td><td><input
type=text name=a_add></td>
</tr>
<tr>
<td><input type=submit value=Show name=submit></td> </tr>
</table>
</center>
</form>
</body>
</html>
(slip_18_insert.php)
<?php
$a_no=$_GET['a_no'];
$a_name=$_GET['a_name'];
$d_join=$_GET['d_join'];
$a_sal=$_GET['a_sal'];
$a_add=$_GET['a_add'];
$con =
mysql_connect("localhost","root","");
$d =
mysql_select_db("bca_programs",$con);
$q2=mysql_query("insert
into emp_slip_18 values($a_no,'$a_name','$d_join',$a_sal,'$a_add')");
echo
"<center><b><h2> Values Inserted
Successfully.....!!!</h2><b></center>";
?>
(slip_18_update.html)
<?php
$edit=$_GET['edit'];
$c=mysql_connect("localhost","root","");
$d=mysql_select_db("bca_programs",$c);
$q=mysql_query("select
* from emp_slip_18");
$row=mysql_fetch_array($q);
?>
<html>
<body>
<form
action="slip_18_update.php" method="get">
<center> <h2>Update Enployee Details :</h2> <br>
<table>
<tr> <td> Employee no :</td><td><input
type=text name=a_no value="<?php echo $row[0];?>"> </td> </tr>
<tr> <td> Employee name :</td><td><input
type=text name=a_name value="<?php echo $row[1];?>"></td> </tr>
<tr> <td> Date Of Join :</td><td><input
type=text name=d_join value="<?php echo $row[2];?>"></td> </tr>
<tr> <td> Salary :</td><td><input
type=text name=a_sal value="<?php echo $row[3];?>"></td> </tr>
<tr> <td> Address :</td><td><input
type=text name=a_add value="<?php echo $row[4];?>"></td> </tr>
<tr>
<td><input type=submit value=Show name=submit></td> </tr>
</table>
</center>
</form>
</body>
</html>
(slip_18_update1.php)
<?php
$a_no=$_GET['a_no'];
$a_name=$_GET['a_name'];
$d_join=$_GET['d_join'];
$a_sal=$_GET['a_sal'];
$a_add=$_GET['a_add'];
$con = mysql_connect("localhost","root","");
$d =
mysql_select_db("bca_programs",$con);
$r=mysql_query("update
emp_slip_18 set
empno=$a_no,ename='$a_name',date_of_join='$d_join',salary='$a_sal',address='$a_add'
where empno=$a_no");
?>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.