Jumat, 09 Oktober 2015

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 .
- XAMPP .
- PhpMyAdmin .
- MySQL Database .

*INFO Learn Php And Buid Cms Project Course 

 




Php Source Code:

<?php
// 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
  mysqli_free_result($result);

// close the connection

  mysqli_close($connect);



///////////////OUTPUT:



php connect to mysql and display data
Data From Database


Bagikan

Jangan lewatkan

PHP Code : How To Connect Php To MySQL Database Using MySQLI
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.