-
Notifications
You must be signed in to change notification settings - Fork 0
/
Users.class.php
42 lines (37 loc) · 1.07 KB
/
Users.class.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
<?php
require_once ("Controller.php");
class Users extends Controller
{
public function add($first_name, $last_name)
{
$sth = $this->dbh->query('INSERT INTO Users (first_name, last_name) VALUES ("'.$first_name.'", "'.$last_name.'")');
header('Location: /');
}
public function edit($first_name, $last_name)
{
$sth = $this->dbh->query('UPDATE Users SET last_name="'.$last_name.'" WHERE first_name="'.$first_name.'"');
header('Location: /');
}
public function delete($first_name)
{
$sth = $this->dbh->query('DELETE FROM Users WHERE first_name="'.$first_name.'"');
header('Location: /');
}
public function show()
{
$sth = $this->dbh->query("SELECT * FROM Users;");
$arr = [];
while ($row = $sth->fetch())
{
// echo var_dump($row);
// echo "<hr>";
$arr[] = $row;
}
echo var_dump($arr);
foreach ($arr as $element)
{
// echo var_dump($element)."<hr>";
echo "<li>$element[0] $element[1]</li><br>";
}
}
}