MySQLi is a PHP Extension which enables PHP to communicate with MySQL Databases. MySQLi comes built in with PHP. MySQLi was introduced with PHP 5.0.
MySQLi is available in procedural & Object Oriented style. MySQLi supports CRUD queries, prepared statements,Multiple statements,Transaction and SQL operations.
Before MySQLi, MySQL (Note: Its not MySQLi ) is the Default extension of PHP for connecting MySQL database. Due to several vulnerabilities in MySQL extention,MySQLi was introduced.
As I showed in the example, I saved the connection to a variable to make it cleaner in code. Otherwise, when you want to query the database, you need to connect EACH time!
It makes the code a lot cleaner!