0% found this document useful (0 votes)
4 views5 pages

PR 5

The document includes PHP scripts for a web application that collects customer information, allows for editing and deleting customer records, and updates employee salary information from a MySQL database. It features HTML forms for user input and PHP code for database interactions. The document serves as a practical guide for implementing basic CRUD operations in a PHP and MySQL environment.

Uploaded by

pateltivr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

PR 5

The document includes PHP scripts for a web application that collects customer information, allows for editing and deleting customer records, and updates employee salary information from a MySQL database. It features HTML forms for user input and PHP code for database interactions. The document serves as a practical guide for implementing basic CRUD operations in a PHP and MySQL environment.

Uploaded by

pateltivr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical-5

5.1 : Write PHP script to connect my SQL server from your website.

<html>
<body>
<h3> Program to collect the customer-information </h3>
<form action ="Display.php" method="get">
<table border="5">
<tr>
<td> Enter Name:</td>
<td> <input type="text" name="name"> </td>
</tr>
<tr>
<td> Enter Address Line1: </td>
<td> <input type="text" name="address1"></td>
</tr>
<tr>
<td> Enter Email-id: </td>
<td> <input type="text" name="email"> </td>
</tr>
<tr>
<td> </td> </tr>
<tr> </tr>
<tr>
<td> <input type="submit" value="Submit"></td>
<td> <input type="Reset" value="Reset"></td>
</tr>
</br>
<a href="<a href="https://krazytech.com/programs/simple-library-management-
system-php-mysql" target="_blank" rel="noopener">Search.html</a>"> To search
click here </a> </td>
</table>
</form>
</body>
</html>
Output:-

5.3 : Write a program to edit name of customer to Bob with cust_no = 1, and to
delete record with cust_no = 3.

<html>
<body>
<form action="processorder.php" method="post">
<table style="border: 0px;">
<tr style="background: #cccccc;">
<td style="width: 150px; text-align: center;">Item</td>
<td style="width: 15px; text-align: center;">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td><input type="text" name="tireqty" size="3"
maxlength="3" /></td>
</tr>
<tr>
<td>Oil</td>
<td><input type="text" name="oilqty" size="3"
maxlength="3" /></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td><input type="text" name="sparkqty" size="3"
maxlength="3" /></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;"><input type="submit"
value="Submit
Order" /></td>
</tr>
</table>
</form>
</body>
</html>

Output :

5.4 : Write a program to read employee information like EMP_no, EMP_name,


designation and salary from EMP table and display all these information using
table format.

<html>
<head>
<title>Update a Record in MySQL Database</title>
</head>
<body>

<?php
if(isset($_POST['update']))
{
$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}

$emp_id = $_POST['emp_id'];
$emp_salary = $_POST['emp_salary'];

$sql = "UPDATE employee ".


"SET emp_salary = $emp_salary ".
"WHERE emp_id = $emp_id" ;

mysql_select_db('');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Employee ID</td>
<td><input name="emp_id" type="text" id="emp_id"></td>
</tr>
<tr>
<td width="100">Employee Salary</td>
<td><input name="emp_salary" type="text" id="emp_salary"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="update" type="submit" id="update" value="Update">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>

Output:

You might also like