forked from jmanosu/CS_340_Final_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listUsers.php
executable file
·58 lines (50 loc) · 1.23 KB
/
listUsers.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$currentpage="List Parts";
include "pages.php";
?>
<html>
<head>
<title>List Parts</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<?php
// change the value of $dbuser and $dbpass to your username and password
include 'connectvars.php';
include 'header.php';
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
// query to select all information from supplier table
$query = "SELECT * FROM HW1 ";
// Get results from query
$result = mysqli_query($conn, $query);
if (!$result) {
die("Query to show fields from table failed");
}
// get number of columns in table
$fields_num = mysqli_num_fields($result);
echo "<h1>Users</h1>";
echo "<table id='t01' border='1'><tr>";
for($i = 0; $i < $fields_num; $i++){
$field = mysqli_fetch_field($result);
echo "<td><b>$field->name</b></td>";
}
echo "</tr>\n";
while($row = mysqli_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell){
echo "<td>$cell</td>";
}
echo "</tr>\n";
}
mysqli_free_result($result);
mysqli_close($conn);
?>
</body>
</html>