Hello guy, today we will learn the affected rows function and it is a function of PHP MySQL. It returns a number of rows that are affected by our query.
The affected_rows / mysqli_affected_rows() function returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query. Return Value: The number of rows affected. -1 indicates that the query returned an error. PHP Version: 5+<?php//DB connectioninclude("DB_connection.php");//::::Object Oriented style::::$connect -> query("SELECT * FROM students");//similar use/*query("INSERT INTO students (column names) value ( values));ORupdate, delete query*/$affectedRows = $connect -> affected_rows;//outputecho "Affected Rows:".$affectedRows;//close connection$connect -> close();//::::Procedural style::::mysqli_query($connect, "SELECT * FROM students");echo "Affected rows: " . mysqli_affected_rows($connect);//close connectionmysqli_close($connect);
Comments
Post a Comment