Actualizar y Borrar
Publicado por Zeno (1 intervención) el 27/06/2017 16:38:29
como hago un actualizar y borrar registro en mysql desde php pero que al actualizar o borrar solo se borre un registro dejo mi codigo para que puedan darme un ejemplo con eso me basta.
index.php
aca el inner join
espero de su colaboracion gracias
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
<?php
session_cache_limiter('nocache,private');
session_name('porcicola');
session_start();
if(empty($_SESSION["uid"]) || empty($_SESSION["pid"]) || empty($_SESSION["correo"]) || empty($_SESSION["usuario"]) || empty($_SESSION["perfil"])){
header('location:/');
}
require_once '../../clases/Conexion.php';
$cnx = new Conexion();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Detalles Medicamento</title>
<link href="../../css/estilos.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="../../images/favicon.png"/>
<link rel="shortcut icon" type="image/png" href="http://eg.com/favicon.png"/>
</head>
<body>
<div class="group">
<input class="form-btn-menu" onClick="window.location.href='/app/'" name="menu" type="button" value="Menú" />
<input class="form-btn-cerrar" onClick="window.location.href='/'" name="cerrar" type="button" value="Cerrar Sesión" />
<br>
<form action="registrarMede.php" method="POST">
<center>
<h2><em>Detalles Medicamento</em></h2>
<label for="detalles_medicamento">Detalles Medicamento <span><em>(requerido)</em></span></label>
<input type="text" name= "detalles_medicamento" class="form-input" required/>
<label for= "medicamento">Medicamento <span><em>(requerido)</em></span></label>
<?php
$sql = "SELECT * FROM medicamento ORDER BY medicamento";
$selectMed = $cnx->ejecutarConsulta($sql, $cnx->consultar);
$comboMed = "<select name='medicamento' class='form-select' required>";
$comboMed.= "<option value=''>Seleccione Medicamento</option>";
if(!isset($selectMed["msg"])){
foreach ($selectMed as $key => $valor) {
$comboMed.= "<option value='{$selectMed[$key]["id_medicamento"]}'>{$selectMed[$key]["medicamento"]} - {$selectMed[$key]["medicamento"]}</option>";
}
}
$comboMed.= "</select>";
echo $comboMed;
?>
<label for="cantidad">Cantidad <span><em>(requerido)</em></span></label>
<input type="text" name= "cantidad" class="form-input" required/>
<label for="lote">Lote <span><em>(requerido)</em></span></label>
<input type="text" name= "lote" class="form-input" required/>
<label for="fecha">Fecha Ingreso <span><em>(requerido)</em></span></label>
<input type="date" name="fecha" class="form-input" step="1" min="2013-01-01" max="2020-12-31" value="<?php echo date("Y-m-d");?>">
<label for="fecha">Fecha Vencimiento <span><em>(requerido)</em></span></label>
<input type="date" name="fecha" class="form-input" step="1" min="2013-01-01" max="2020-12-31" value="<?php echo date("Y-m-d");?>">
</center>
<center>
<input class="form-btn" name="submit" type="submit" value="Registrar" />
<input class="form-btn" onClick="window.location.href='medicamento_detalle.php'" name="medicamento_detalle" type="button" value="Detalles Medicamento" />
</center>
</p>
</form>
</div>
</body>
</html>
aca el inner join
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
114
115
116
117
118
119
120
<?php
session_cache_limiter('nocache,private');
session_name('porcicola');
session_start();
if(empty($_SESSION["uid"]) || empty($_SESSION["pid"]) || empty($_SESSION["correo"]) || empty($_SESSION["usuario"]) || empty($_SESSION["perfil"])){
header('location:/');
}
require_once '../../clases/Conexion.php';
$cnx = new Conexion();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Detalles Medicamento </title>
<link href="../../css/estilos.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="../../images/favicon.png"/>
<!-- Bootstrap -->
<link href="/bootstrap/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/bootstrap/css/dataTables.bootstrap.min.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/bootstrap/js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script src="/bootstrap/js/jquery.dataTables.min.js"></script>
<script src="/bootstrap/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#tabla').DataTable();
} );
</script>
</head>
<body>
<div class="divBooststrap">
<input class="form-btn-menu" onClick="window.location.href='/app/'" name="menu" type="button" value="Menú" />
<input class="form-btn-cerrar" onClick="window.location.href='/'" name="cerrar" type="button" value="Cerrar Sesión" />
<br>
<center><h2><em>DETALLES MEDICAMENTO </em></h2></center>
<div class="container">
<div class="table-responsive">
<table id="tabla" class="hover" width="100%">
<thead>
<tr>
<th class="col-md-3">ID</th>
<th class="col-md-3">DETALLES MEDICAMENTO</th>
<th class="col-md-3">MEDICAMENTO</th>
<th class="col-md-3">CANTIDAD</th>
<th class="col-md-3">LOTE</th>
<th class="col-md-3">FECHA INGRESO</th>
<th class="col-md-3">FECHA VENCIMIENTO</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT id_medicamento_detalle,
medicamento,
med.id_medicamento,
mdm.cantidad,
lote,
fecha_ingreso,
fecha_vencimiento
FROM medicamento_detalle mdm
inner join medicamento med on med.id_medicamento = mdm.id_medicamento";
$selectMed = $cnx->ejecutarConsulta($sql, $cnx->consultar);
if(!isset($selectMed["msg"])){
$html = "";
foreach ($selectMed as $key => $valor) {
$html.= "<tr>";
$html.= "<td>{$selectMed[$key]["id_medicamento_detalle"]}</td>";
$html.= "<td>{$selectMed[$key]["medicamento"]}</td>";
$html.= "<td>{$selectMed[$key]["cantidad"]}</td>";
$html.= "<td>{$selectMed[$key]["lote"]}</td>";
$html.= "<td>{$selectMed[$key]["fecha_ingreso"]}</td>";
$html.= "<td>{$selectMed[$key]["fecha_vencimiento"]}</td>";
$html.= "</tr>";
}
echo $html;
}
else {
echo $selectMed["msg"];
}
?>
</tbody>
</table>
</div>
</div>
<br>
<?php
if ($_SESSION["pid"]==="1") {
?>
<center>
<input class="form-btn" onClick="window.location.href='/app/medide/'" name="submit" type="button" value="Atrás" />
</center>
<?php
}else if ($_SESSION["pid"]==="2") {
?>
<center>
<input class="form-btn" onClick="window.location.href='/app/'" name="submit" type="button" value="Atrás" />
</center>
<?php
}
?>
</div>
<script type="text/javascript">
$('#tabla')
.removeClass( 'display' )
.addClass('table');
</script>
</body>
</html>
Valora esta pregunta
0