0% found this document useful (0 votes)
3 views4 pages

php_prac_16

The document contains two PHP programs for database operations. The first program updates a student's record in the 'Student' table, while the second program deletes a record from the same table. Both programs establish a connection to a MySQL database and handle success or error messages accordingly.

Uploaded by

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

php_prac_16

The document contains two PHP programs for database operations. The first program updates a student's record in the 'Student' table, while the second program deletes a record from the same table. Both programs establish a connection to a MySQL database and handle success or error messages accordingly.

Uploaded by

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

Practical No.

16
1) Write a program to update a record in table.
<?php

$servername="localhost";

$password="";

$username="root";

$dbname="saee_db";

$res=mysqli_connect($servername,$username,$password,$dbname);

if($res)

echo "Connection established...<br>";

else

echo "Connection not established...<br>";

$sql="update Student set first_name='sakshi',email='[email protected]' where id=104";

if(mysqli_query($res,$sql))

echo "Record updated...<br>";

else

echo "Record not updated...".mysqli_error($res);

?>
Output:
2) Write a program to delete a record in table.
<?php

$servername="localhost";

$password="";

$username="root";

$dbname="saee_db";

$res=mysqli_connect($servername,$username,$password,$dbname);

if($res)

echo "Connection established...<br>";

else

echo "Connection not established...<br>";

$sql="delete from Student where id=104";

if(mysqli_query($res,$sql))

echo "Record deleted...<br>";

else

echo "Record not deleted...".mysqli_error($res);

?>
Output:

You might also like