Repository navigation
Expand file tree
/
Copy pathdatabaseDisplay.php
More file actions
113 lines (96 loc) · 2.66 KB
/
Copy pathdatabaseDisplay.php
File metadata and controls
113 lines (96 loc) · 2.66 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<html>
<? include('dbc.php'); ?>
<link rel="stylesheet" href="styles.css">
<body>
<?php
$link = $dbc;
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
echo "<p> mysqli_query test </p>";
$sql =
"SELECT *
FROM angry_wipes_test
ORDER BY unit"
;
if(!$result = $link->query($sql)){
die('There was an error running the query [' . $link->error . ']');
}
$sicuTotal = 0;
$micuTotal = 0;
while($row = $result->fetch_assoc()){
echo $row['player']. ' '. $row['unit']. '<br />';
if ($row['unit'] == 'SICU') { $sicuTotal ++;}
else if ($row['unit'] == 'MICU'){ $micuTotal++;}
}
echo ' <br/>';
echo 'SICU total: ' . $sicuTotal. '<br/>';
echo 'MICU total: ' . $micuTotal. '<br/>';
echo 'Total results: ' . $result->num_rows . '<br/>';
$arg = "SICU";
$arg1 = "mike";
$stmt = $link->prepare("SELECT * FROM angry_wipes_test WHERE unit = ? AND player = ?");
$stmt->bind_param("ss", $arg, $arg1);
$stmt -> execute();
$result = $stmt->get_result();
while ($row = $result -> fetch_assoc()){
echo $row['unit']. '<br/>';
}
// ----------------
// $result=mysqli_query($link, $sql);
// $num=mysql_numrows($result);
//
//
// $i=0;
// while ($i < $num) {
//
// $player=mysql_result($result,$i,"angry_wipes_test.player");
// $unit=mysql_result($result,$i,"angry_wipes_test.unit");
// $date=mysql_result($result,$i,"angry_wipes_test.comp_date");
//
// };
//
// echo "<b> $player </b>
// <b> $unit </b>
// <b> $date </b></br>";
// $i++;
// }
//
// echo 'Total results: ' . $result->num_rows;
//
echo "<p> ending mysqli test</p>";
// $query="SELECT
// emp.first_name,
// emp.last_name,
// emp.BLS,
// FROM emp
// ORDER BY
// emp.BLS ASC";
// $result=mysqli_query($link, $query);
// $num=mysql_numrows($result);
// mysqli_close();
//
// $i=0;
// while ($i < $num) {
//
// $rowClass = 'green';
// $first=mysql_result($result,$i,"emp.first_name");
// $last=mysql_result($result,$i,"emp.last_name");
// $BLS=mysql_result($result,$i,"emp.BLS");
// $rowClass = 'green';
// if ($first == 'Mike') {
// $rowClass = 'red';
// };
//
// echo "<b class=" .$rowClass ."> $first </b>
// <b> $last </b>
// <b> $BLS </b></br>";
// $i++;
// }
mysqli_close($link);
?>