PHP Code : How To Connect Php To MySQL Database Using MySQLI

PHP And MySQL Code : How To Connect Php And MySQL Database And Display Data.


In this Php Tutorial we will Learn How To Connect PHP With MySQL Database  And Show Database Table Data using MySQLI .
I Use In This Tutorial:
- NetBeans IDE .
- PhpMyAdmin .
- MySQL Database .

*INFO Learn Php And Buid Cms Project Course 


Php Source Code:

// create a connection between php and mysql database

$hostname = "localhost";

$username = "root";

$password = "";

// your database name

$databaseName = "test_db";

// create The connection

$connect = mysqli_connect($hostname, $username, $password);
mysqli_select_db($connect, $databaseName);

// the mysql query

$query = "SELECT * FROM `users`";

$result = mysqli_query($connect, $query);

// using while loop to dispaly data from database

while($row = mysqli_fetch_array($result))

    echo "$row[0] - $row[1] - $row[2] - $row[3]<br>";


// free your result

// close the connection



php connect to mysql and display data
Data From Database

Share this

Related Posts

Next Post »