PHP Tutorial

Define PHP

PHP Installation

PHP INI File

PHP Comment

PHP Case Sensitivity

PHP Variable, DataType

PHP Echo & Print

PHP Operators

PHP Receiving Input

Decision Making - if...else

PHP Switch Case

PHP Loops

PHP Jumping Statement

PHP Image Gallery

PHP File Upload

PHP Arrays

PHP Date Functions

PHP String Functions

PHP Math Functions

PHP Functions

PHP Variable Scope

PHP Constant Variable

PHP Superglobals

PHP Form Validation

PHP Include Statement

PHP Filter

PHP File Handling

PHP Cookies

PHP Session

PHP Send Emails

PHP Captcha

PHP MySQL Select

PHP MySQL Insert

PHP MySQL Delete

PHP MySQL Update

PHP MySQL Injection

PHP Assignment

Page Stats

Visitor: 291

PHP MySql Update

In PHP, we can execute a update MySql statement to update records in the database table. First we need to create a MySql connection, write the sql update query, execute the query and to update records.

Example 1: Create a MySql connection, execute the update query to update records in the MySql table.

<?php
	$conn = mysqli_connect("localhost", "root" , "", "student");
	
	if($conn === false){
		die("ERROR: Could not connect to database.");
	}
	
	$sql = "update book set class=3 where id=3";
	$result = mysqli_query($conn, $sql);
	
	if($result==1)
		echo "record updated";
	else
		echo "error";
	
	mysqli_close($conn);
?>
Advertisement