rohidas

Hi I am Rohidas lande.I have teaching in C.D.jain college of commerce Shrirampur .I have Nine year in teaching Experience to teach various programming langauge,script languages,databases like Java,C,C++,php,python,html,css,javascript,mysql,oracle.

PHP_assignment7

Savitribai Phule Pune University S. Y. B. B. A. (C. A.) Semester-III (CBCS 2019 Pattern) CA-306: Lab Book Credits-03 Assignment 7:Database PHP ASSIGNMENT
Sr.NoAssignment name
Set-A
1
Write a PHP script to create an employee table using attributes employee number, employee name, address joining date and salary.If a table is created then display the appropriate message otherwise end the PHP script. Plz Click on Question to see Answer

<?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connect". "</br>" mysql_select_db("company"); echo "database seleted". "</br>"; //echo"-------------------create table procedure---------------------"; $query="create table employee(emp_no int primary key, emp_name varchar(12),emp_address varchar(23),salary int)"; if(mysql_query($query)) { echo "table created successfully"; } else { die('cannot create table'.mysql_error()); } ?>


2
Write a PHP script to accept account details(account number,account type and balance).Store these details in the account table and display an appropriate message. Plz Click on Question to see Answer

<?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connect"."</br>"; mysql_select_db("company"); echo "database seleted"."</br>"; $query="create table account(account_no int primary key, account_type varchar(12),balance int)"; if(mysql_query($query)) { echo "table created successfully"; } else { die('cannot create table'.mysql_error()); } mysql_close($con); ?>


3
Write a PHP script to accept product number from the user.Update the price of the product and display an appropriate message. Plz Click on Question to see Answer

<?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connect". "</br>"; mysql_select_db("company"); echo "database seleted". "</br>”; $query="create table product(product_no int primary key, product_name varchar(12),product_price int)"; if(mysql_query($query)) {echo "table created successfully"; } else { die('cannot create table'.mysql_error());} $update="update product set product_price=200 where product_no=100"; if(mysql_query($update)) {echo " update data successfully";} else {die('cannot update data'.mysql_error());} mysql_close($con); ?>


Set-B
1
Consider the following entities and their relationships. Employee(eno,ename,sal)Project(pno, pname,duration) Employee and Project are related with a many-many relationship. Create a RDB in 3 NF for the above.Using the above database.write a PHP script to accept the project name. Display the name of the employees and the duration of the project. Plz Click on Question to see Answer

<html><body> <form method="post" action="assignment.php"> enter the project name:<input type="text" name="p1"><br> <input type="submit" value="submit"> </form></body></html> Assignment.php <?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connect". "</br>"; mysql_select_db("gauri"); echo "database seleted"."</br>"; $p1=$_POST['p1']; $query1="select employee.eno,ename,pname, duration from employee,project,ep where pname='$p1' and employee.eno=ep.eno and project.pno=ep.pno"; $result=mysql_query($query1); echo "<table border=10 cellspacing=1 cellpadding=1>"; echo "<tr><th>< font color=blue>emp_no</th> <th><font color=blue> emp_name</th> <th><font color=blue> project_name</th> <th><font color=blue> duration</th></tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td align='center'>"."<font color=red>" .$row['eno']."</td><td align='center'>"."< font color=red>".$row['ename']. "</td><td align='center'>"."<font color=red>" .$row['pname']. "</td><td align='center'>"."<font color=red>" .$row['duration']." </td></br></tr>"; } echo "</table>"; mysql_close($con); ?>


2
Consider the following entities and their relationships.Train(t_no,t_name) Passenger(p_no,P_name,addr,age)The relationship between Train and Passenger is many-to-many with descriptive attribute date,seat_no and amt. Create a RDB in 3 NF for the above. Using the above database write a PHP script to accept a date. Display train details having maximum passenger for a given date. Plz Click on Question to see Answer

<html><body> <form method="post" action="assignment.php"> enter the date:<input type="text" name="p1"><br> <input type="submit" value="submit"> </form></body></html> assignment.php <?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connect"."</br>"; mysql_select_db("gauri"); echo "database seleted"."</br>"; $p1=$_POST['p1']; $query1="select train.t_no,t_name,p_name,date from train,passenger,tp where date='$p1' and train.t_no=tp.t_no and passenger.p_no=tp.p_no"; $result=mysql_query($query1); echo "<table border=10 cellspacing=1 cellpadding=1>"; echo "<tr><th><font color=blue>train_no</th> <th><font color=blue> train_name</th> <th><font color=blue>passenger_name</th> <th><font color=blue>date</th></tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td align='center'>"."< font color=red>".$row['t_no']. "</td><td align='center'>"."< font color=red>".$row['t_name']. "</td><td align='center'>"."< font color=red>".$row['p_name']. "</td><td align='center'>"."< font color=red>".$row['date']."</td></br></tr>"; } echo "</table>"; mysql_close($con); ?>


3
Consider the following entities and their relationships. Crop (c_no, c_name, c_season, pesticides) Farmer (f_no, f_name, f_location) The relationship between Crop and Farmer is many-to-many with descriptive attribute year.Create a RDB in 3 NF for the above. Using the above database write a PHP script to accept crop name and year value. Display total number of farmers harvesting given crop in a given year. Plz Click on Question to see Answer

<html><body> <form method="post" action="assignment.php"> enter the crop name:<input type="text" name="p1"><br> enter the year:<input type="text" name="p2"><br> <input type="submit" value="submit"> </form></body></html> Assignment.php <?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connected"."</br>"; mysql_select_db("gauri"); echo "database seleted";echo "</br>"; $p1=$_POST['p1']; $p2=$_POST['p2']; $query1="select farmer.f_no,c_name,f_name,year from crop,farmer,cf where c_name='$p1' and year='$p2' and crop.c_no=cf.c_no and farmer.f_no=cf.f_no"; $result=mysql_query($query1); echo "<table border=10 cellspacing=1 cellpadding=1>"; echo "<tr><th>< font color=blue>farmer_no</th> <th><font color=blue> crop_name</th> <th><font color=blue>farmer_name</th> <th><font color=blue>year</th></tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td align='center'>"."< font color=red>".$row['f_no']. "</td><td align='center'>". "<font color=red>".$row['c_name']."</td> <td align='center'>". "< font color=red>".$row['f_name']. "</td><td align='center'>". "<font color=red>".$row['year']." </td></br></tr>"; } echo "</table>"; mysql_close($con); ?>


Set-C
1
1.Consider the following entities and their relationships.Client(c_no,c_name,c_addr,birth_date). Policy_info(p_no,p_name,maturity_amt,prem_amt,policy_term).The relationship between Client and Policy_info is many-to-many with descriptive attribute date_of_purchase.Create a RDB in 3NF for the above Using the above database write a PHP script to display policy details of a given client for a given year in the following format. Plz Click on Question to see Answer

<html><body> <form method="post" action="assignment.php"> enter the client name:< input type="text" name="p1"><br> enter the year:<input type="text" name="p2"><br> <input type="submit" value="submit"> </form></body></html> Assignment.php <?php $con=mysql_connect("localhost","root",""); if(!$con) { die('cannot connect'.mysql_error()); } echo "database connect"."</br>"; mysql_select_db("gauri"); echo "database seleted"."</br><br>"; $p1=$_POST['p1']; $p2=$_POST['p2']; echo "<b>client name:$p1</b>"."<br>"; echo "<b>year:$p2</b>"."<br>"; $query1="select p_name,maturity_amt,prem_amt,policy_term, date_of_purchase from client,policy_info,cp where c_name='$p1' and client.c_no=cp.c_no and policy_info.p_no=cp.p_no"; $result=mysql_query($query1); echo "<table border=10 cellspacing=1 cellpadding=1>"; echo "<tr><th>< font color=blue>policy name</th> <th><font color=blue> maturity amount</th> <th><font color=blue> premium amount</th> <th><font color=blue>policy term</th> <th><font color=blue> date of purchase</th></tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td align='center'>"."< font color=red>".$row['p_name']. "</td><td align='center'>"." <font color=red>".$row['maturity_amt']. "</td><td align='center'>"." <font color=red>".$row['prem_amt']. "</td><td align='center'>"." <font color=red>".$row['policy_term']. "</td><td align='center'>"." <font color=red>".$row['date_of_purchase']." </td></br></tr>"; } echo "</table>"; mysql_close($con); ?>


Post a Comment

0 Comments