-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
96 lines (90 loc) · 3.5 KB
/
index.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<title>PHP CRUD</title>
</head>
<body>
<?php require_once 'processo.php'; ?>
<?php
if (isset($_SESSION['message'])): ?>
<div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif ?>
<div class="container col-5 pt-3">
<div class="container">
<?php
$mysqli = new mysqli('localhost', 'root', '', 'CRUD') or die(mysqli_error($mysqli));
$result = $mysqli->query("SELECT * FROM data") or die($mysqli->error);
//pre_r($result);
?>
<div class="row justify-content-center">
<table class="table">
<thead>
<tr>
<th>Nome</th>
<th>regiao</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php
while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $row['nome']; ?></td>
<td><?php echo $row['regiao']; ?></td>
<td>
<a href="index.php?edit=<?php echo $row['id']; ?>"
class="btn btn-info">Edit</a>
<a href="processo.php?delete=<?php echo $row['id']; ?>"
class="btn btn-danger">Delete</a>
</td>
</tr>
<?php endwhile; ?>
</table>
</div>
<?php
function pre_r( $array ){
echo '<pre>';
print_r($array);
echo '</pre>';
}
?>
<div class="row justify-content-center">
<form action="processo.php" method="POST">
<img src="./img/logo2.gif" alt="" width="320" height="200" class="mx-auto d-block">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="form-group">
<label for="">Nome</label>
<input type="text" name="nome" class="form-control"
value="<?php echo $nome; ?>" placeholder="Digite seu nome">
</div>
<div class="form-group">
<label for="">Reigiao</label>
<input type="text" name="regiao" class="form-control"
value="<?php echo $regiao; ?>" placeholder="Digite sua regiao">
</div>
<div class="form-group">
<?php
if ($update == true):
?>
<button type="submit" class="btn btn-info" name="update">Update</button>
<?php else: ?>
<button type="submit" class="btn btn-primary" name="save">Save</button>
<?php endif; ?>
</div>
</form>
</div>
</div>
</div>
</body>
</html>