-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFetchArray.php
More file actions
44 lines (30 loc) · 906 Bytes
/
Copy pathtestFetchArray.php
File metadata and controls
44 lines (30 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once('db.class.php');
$mysql = new db();
$connection = $mysql->Connect();
//Command
$sqlCommand = "SELECT * FROM users";
//Execute
$result = mysqli_query($connection, $sqlCommand);
if (!$result) {
echo 'There is an error in the database. Try again later.';
} else {
//Only one line
//$users = mysqli_fetch_array($result);
//$users = mysqli_fetch_array($result, MYSQLI_NUM);
//$users = mysqli_fetch_array($result, MYSQLI_ASSOC);
//Multiple register
$users = array();
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$users[] = $row;
}
/*
foreach($users as $user) {
var_dump($user);
echo '<br>';
echo '<br>';
}
*/
echo $users[0]['username'];
}
?>