//Example of fetching data from a database using mysqli_connect

//Make a connection to the database
$link = mysqli_connect("databasehostname", "databaseusername", "databasepassword", "databasename");

//Check the connection
if (!$link) {
    printf("Could not connect to database: %s\n", mysqli_connect_error());

//Create the sql query
$query = "SELECT * FROM staff ";

//Execute the query against the database 
$result = mysqli_query( $link, $query );

if (!$result) {  //Display any error message 
    printf("Error in connection: %s\n", mysqli_error($link));

//Fetch the result into an associative array
while ( $row = mysqli_fetch_assoc( $result ) ) {
	$table[] = $row;	//add each row into the table array

//Display the rows
if ($table) { //Check if there are any rows to be displayed
	//Retrieve each element of the array
	foreach($table as $d_row) {
		echo( $d_row["first_name"] . " " . $d_row["last_name"] . "<br/>" );
	echo("No rows to be displayed");

//Close the connection