Connect PHP with MySQL through mysqli_connect

This time I will show you how to make a simple connection with PHP and MYSQL using the PHP extension for mysqli databases since «mysql_connect» that was used in PHP4 and at the beginning of PHP5 has become obsolete, let’s start with the example:

query($query);
?>

Simple connection and query example mysql-php

    ". $row["field1"] . " " . $row["field2"] . ""; } ?>

I will explain some details of the presented code
1- Once the connection is made, some methods are available, such as query ($ connection-> query ($ query);) with which we have made our query after having established our connection.

2- Through while ($ row = mysqli_fetch_array ($ result)) we iterate through each of the elements of our array obtained from the query.

3- With the variable plus the name of the field we can obtain its value ($ row [«field_name»])

I hope it will be useful later.

También te podría gustar...