-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
87 lines (71 loc) · 2.61 KB
/
index.php
File metadata and controls
87 lines (71 loc) · 2.61 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
<!DOCTYPE HTML>
<? require_once('controller.php'); ?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Simple Crud</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.apagar').click(function(){
$.ajax({
type: "POST",
url: "controller.php",
data: 'id='+$(this).attr('href')+'&metodo=delete',
success: function(retorno){
if(retorno.falha == 'true'){
alert(retorno.mensagem);
}else{
alert(retorno.mensagem);
window.location.reload(true);
}
},
dataType: 'json'
});
return false;
});
});
</script>
</head>
<body>
<h2>Simple crud</h2>
<a href="adicionar.php">Adicionar</a>
<br />
<table border="2">
<thead>
<tr>
<th>#</th>
<th>Nome</th>
<th>Profissão</th>
<th>Ação</th>
</tr>
</thead>
<tbody>
<?
$dados = $controller->index();
if($dados){
foreach($dados as $row){
?>
<tr>
<td><?=$row['id'];?></td>
<td><?=$row['nome'];?></td>
<td><?=$row['profissao'];?></td>
<td>
<a href="editar.php?id=<?=$row['id'];?>">Editar</a>
<br />
<a class="apagar" href="<?=$row['id'];?>">Apagar</a>
</td>
</tr>
<?
}
}else{
?>
<tr>
<td colspan="4">Sem dados</td>
</tr>
<? } ?>
</tbody>
</table>
</body>
</html>