1) Write PHP program to select list of subjects (use multivalued parameter) displays on next page.(Use listbox to select subject)
slip20.html
<HTML>
<BODY>
<FORM ACTION="multicheck.php" method="post">
Subjects:<select name="tech[]" size=6 multiple>
<option value="php">PHP</option>
<option value="asp">ASP</option>
<option value="jsp">JSP</option>
<option value="c++"> PHP</option>
</select>
<br/>
<input type="submit" value="Display" />
</form>
</body>
</html>
multicheck.php
<?php
//$name = $_POST['uname'];
$tech = $_POST['tech'];
if(is_array($tech)) {
foreach($tech as $v) echo $v."<br/>";
}
else echo $tech."<br/>";
?>
slip20.html
<HTML>
<BODY>
<FORM ACTION="multicheck.php" method="post">
Subjects:<select name="tech[]" size=6 multiple>
<option value="php">PHP</option>
<option value="asp">ASP</option>
<option value="jsp">JSP</option>
<option value="c++"> PHP</option>
</select>
<br/>
<input type="submit" value="Display" />
</form>
</body>
</html>
multicheck.php
<?php
//$name = $_POST['uname'];
$tech = $_POST['tech'];
if(is_array($tech)) {
foreach($tech as $v) echo $v."<br/>";
}
else echo $tech."<br/>";
?>
2)Consider
the following entities and their relationships
Emp (emp_no,emp_name,address,phone,salary)
Dept (dept_no,dept_name,location)
Emp-Dept
are related with one-many relationship
Create
a RDB in 3NF for the above and solve following
Using
above database write a PHP script which will
1.Insert
employee records in table .
2.Print
a salary statement in the format given below, for a given department. (Accept
department name from the user).
Maximum
Salary
|
Minimum Salary
|
Sum Salary
|
slip20.html
<html>
<body>
<form
action="slip20.php" method="get">
<center><h2>Enter
Employee Details : </h2>
<table border=1>
<tr>
<td>Enter
Employee No :</td>
<td><input
type=text name=e_no></td>
</tr>
<tr>
<td>Enter
Employee Name :</td>
<td><input type=text
name=e_nm></td>
</tr>
<tr>
<td>Enter Address
:</td>
<td><input
type=text name=add></td>
</tr>
<tr>
<td>Enter Phone
:</td>
<td><input
type=text name=ph></td>
</tr>
<tr>
<td>Enter Salary
:</td>
<td><input
type=text name=sal></td>
</tr>
<tr>
<td>Enter
Department no :</td>
<td><input
type=text name=d_no></td>
</tr>
<tr>
<td>Enter
Department name :</td>
<td><input
type=text name=d_nm></td>
</tr>
<tr><td>Enter
Location :</td>
<td><input
type=text name=loc></td>
</tr>
<tr>
<td></td>
<td><input
type=submit value=OK></td>
</tr>
</table>
</center>
</form>
</body>
</html>
slip20.php
<?php
$e_no=$_GET['e_no'];
$e_name=$_GET['e_nm'];
$add=$_GET['add'];
$ph=$_GET['ph'];
$sal=$_GET['sal'];
$d_no=$_GET['d_no'];
$d_nm=$_GET['d_nm'];
$loc=$_GET['loc'];
$con=mysql_connect("localhost","root","");
$d=mysql_select_db("archana",$con);
$q=mysql_query("insert
into emp values($e_no,'$e_name','$add',$ph,$sal)");
$q1=mysql_query("insert
into dept values($d_no,'$d_nm','$loc',$e_no)");
$q2=mysql_query("select
min(sal),max(sal),sum(sal) from emp");
echo"<table
border='1'>";
echo
"<tr><td>Minimum salary----</td><td>Maximum
salary----</td><td>Sum of Salary</td></tr>";
while($row=mysql_fetch_array($q2))
{
echo"<tr><td>";
echo $row['min(sal)'];
echo"</td><br><br>
<td>";
echo $row['max(sal)'];
echo"</td><br><br><td>";
echo $row['sum(sal)'];
echo"</td></tr>";
}
echo"</table>";
mysql_close();
?>