0% found this document useful (0 votes)
72 views2 pages

Retrieving Data From A Database

This document contains PHP code to retrieve data from a database. It connects to a MySQL database called "cl20-exampledb" and selects all records from the "users" table. It then fetches the results as an array and prints them out, or echoes an error message if the query fails.

Uploaded by

MirunaCatiche
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views2 pages

Retrieving Data From A Database

This document contains PHP code to retrieve data from a database. It connects to a MySQL database called "cl20-exampledb" and selects all records from the "users" table. It then fetches the results as an array and prints them out, or echoes an error message if the query fails.

Uploaded by

MirunaCatiche
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Retrieving Data From A Database:

[Link]
!

<?php

$link = mysqli_connect("localhost", "cl20-exampledb", "K7.7grb-Y", "cl20-

exampledb");

if (mysqli_connect_error()) {

die("Could not connect to database");


$query = "SELECT * FROM users";

if ($result=mysqli_query($link, $query)) {

$row = mysqli_fetch_array($result);

print_r($row);

} else {



?>

echo "It failed";

You might also like