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

Mysql Update&delete

The document contains PHP code for updating and deleting student records in a MySQL database. It includes HTML forms for user input, where users can enter a student ID and name to update or just an ID to delete a record. The code handles database connections, executes SQL queries, and provides feedback on the success or failure of the operations.
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)
3 views4 pages

Mysql Update&delete

The document contains PHP code for updating and deleting student records in a MySQL database. It includes HTML forms for user input, where users can enter a student ID and name to update or just an ID to delete a record. The code handles database connections, executes SQL queries, and provides feedback on the success or failure of the operations.
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/ 4

Updating data

<html>

<form method="POST">

id: <input type="text" name="id"><br>

name:<input type="text" name="n1"><br>

<input type="submit" name="s" value="update"><br>

view student details<a href="dis.php">click here</a>

</form>

<?php

$conn=mysqli_connect('localhost','root','','student');

if($conn->connect_error)

die("connection failed".$conn->connect_error);

echo "connection successful";

if(isset($_POST['s']))

$id=$_POST['id'];

$n=$_POST['n1'];

$sql="update stud_details set s_name='$n' where s_id='$id'";

if(mysqli_query($conn,$sql)){

echo "updated successfully";

else

echo "error";
}

?> <html>

<form method="POST">

id: <input type="text" name="id"><br>

name:<input type="text" name="n1"><br>

<input type="submit" name="s" value="update"><br>

view student details<a href="dis.php">click here</a>

</form>

<?php

$conn=mysqli_connect('localhost','root','','student');

if($conn->connect_error)

die("connection failed".$conn->connect_error);

echo "connection successful";

if(isset($_POST['s']))

$id=$_POST['id'];

$n=$_POST['n1'];

$sql="update stud_details set s_name='$n' where s_id='$id'";

if(mysqli_query($conn,$sql)){

echo "updated successfully";

else

echo "error";
}

?>

Deleting data
<html>

<form method="POST">

id: <input type="text" name="id"><br>

<input type="submit" name="s" value="delete"><br>

</form>

<?php

$conn=mysqli_connect('localhost','root','','student');

if($conn->connect_error)

die("connection failed".$conn->connect_error);

echo "connection successful";

if(isset($_POST['s']))

$id=$_POST['id'];

$sql="delete from stud_details where s_id='$id'";

if(mysqli_query($conn,$sql)){

echo "deleted successfully";

else

echo "error".$connect_error;

<html>
<form method="POST">

id: <input type="text" name="id"><br>

<input type="submit" name="s" value="delete"><br>

</form>

<?php

$conn=mysqli_connect('localhost','root','','student');

if($conn->connect_error)

die("connection failed".$conn->connect_error);

echo "connection successful";

if(isset($_POST['s']))

$id=$_POST['id'];

$sql="delete from stud_details where s_id='$id'";

if(mysqli_query($conn,$sql)){

echo "deleted successfully";

else

echo "error".$connect_error;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy