//$query="INSERT INTO student_max SELECT * from student ";
/*$query ="INSERT INTO `student_max` (`id`, `name`, `class`, `mark`, `sex`) VALUES
(35, 'John Alex', 'Five', 80, 'male'),
(35, 'John Alex', 'Five', 80, 'female')";
*/
//$query ="ALTER TABLE `student_max` CHANGE `id` `id` INT( 4 ) NOT NULL DEFAULT '0'";
$query ="UPDATE `student_max` SET mark = mark+2"; // affect all rows
if($connection->query($query)){
echo "No of records Updated : ".$connection->affected_rows;
}else{
echo $connection->error;
}
echo "<br>";
echo $connection->info;
Output
Rows matched: 35 Changed: 35 Warnings: 0
The above output is based on query UPDATE `student_max` set mark = mark+2 You can try other queries.
$mysqli->info
mysqli_info ( mysqli $link )
$mysqli : database connection string or Link | Query | Possible mysqli_info return values |
|---|---|
| INSERT INTO `student_max` (`id`, `name`, `class`, `mark`, `sex`) VALUES (35, 'John Alex', 'Five', 80, 'male'), (35, 'John Alex', 'Five', 80, 'female') | Records: 2 Duplicates: 0 Warnings: 0 |
| INSERT INTO student_max SELECT * from student | Records: 35 Duplicates: 0 Warnings: 0 |
| LOAD DATA INFILE ... | Records: 1 Deleted: 0 Skipped: 0 Warnings: 0 |
| ALTER TABLE `student_max` CHANGE `id` `id` INT( 3 ) NOT NULL DEFAULT '0' | Records: 0 Duplicates: 0 Warnings: 0 |
| UPDATE `student_max` set mark=mark+2 | Rows matched: 35 Changed: 35 Warnings: 0 |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.