valore manipulacion
Publicado por noe (186 intervenciones) el 17/07/2020 23:33:58
Hola foro !!!
tengo 2 script y funcionan bien lo unico que no he podido es la manipulacion del valor de la variable, el dato que trae es una fecha ejemplo (1954-09-20) lo que pretendo es sacar el año de la fecha para poder calcular su edad del paciente les muestro los 2 script.
alta_consulta1.php
alta_consulta2.php
GRACIAS.
tengo 2 script y funcionan bien lo unico que no he podido es la manipulacion del valor de la variable, el dato que trae es una fecha ejemplo (1954-09-20) lo que pretendo es sacar el año de la fecha para poder calcular su edad del paciente les muestro los 2 script.
alta_consulta1.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
97
98
99
100
101
102
103
104
105
<?php
session_start();
date_default_timezone_set('America/Mexico_City');
$fecha = date("Y-m-d") ;
if ($_SESSION["usuario"]){
//echo $_SESSION["usuario"];
require ("conecta.php");
$busca = "SELECT MAX(con_id) as maximo from consulta";
$lista = mysqli_query($conectado,$busca);
$dato = mysqli_fetch_assoc($lista);
$max_fol= $dato[maximo] + 1;
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Consulta</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function CedulaPaciente(id){
$.post("alta_consulta2.php",{ClaveId:id},function(retorno){
registro = retorno.split("/");
$('#nomp').val(registro[0]);
$('#fecp').val(registro[1]);
});
}
</script>
</head>
<body>
<div class="caja">
<form name="f" action="alta_consulta3.php" method="post">
<br />
<table width="746" align="center">
<tr>
<td width="130">Num. Expediente</td>
<td width="370"><input type="text" name="nuex" class="alto1" value="<?php echo $max_fol; ?>"></td>
<td width="55" align="right">Fecha </td>
<td width="20"><input type="date" name="fein" value="<?php echo $fecha; ?>" class="alto1"></td>
</tr>
<tr>
<td>Cedula Prof.</td>
<td><input type="text" name="cepo" class="alto1" autofocus="on"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Nombre Medico</td>
<td><input type="text" name="nome" id="nomm" class="alto1 largo2"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Cedula Paciente</td>
<td><input type="text" name="cepa" onchange="CedulaPaciente(this.value)" class="alto1"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Nombre Paciente</td>
<td><input type="text" name="nopa" id="nomp" class="alto1 largo2"></td>
<td align="right">Edad </td>
<?php
if (isset($cepa)){
//$ant = $('#fecp').val($registro[1]);
//$ant = ($registro[1]);
$ant = $_SESSION["pasofecha"];
$act = $fecha;
$old = explode("-", $ant);
$new = explode("-", $act);
$anios = $new[0] - $old[0];
}
?>
<td><input type="text" name="edpa" value="<?php echo $anios; ?>" class="alto1 largo1"> Años</td>
</tr>
</table>
<table width="746" align="center">
<tr>
<td colspan="2" align="center">MEDICAMENTO</td>
<td colspan="2" align="center">INDICACIONES</td>
</tr>
<tr>
<td colspan="2"><textarea name="med" rows="8" cols="48"><?php echo $new[0] ;?></textarea></td>
<td colspan="2"><textarea name="ind" rows="8" cols="48"></textarea></td>
</tr>
</table>
<br /><br />
</form>
<div id="botones">
<input type="button" value="Registra Consulta" class="btn btn-azu" onclick="registra()" tabindex="10"/>
<input type="button" value="Limpia" class="btn btn-azu" onclick="window.location='alta_consulta1.php'" tabindex="11"/>
<input type="button" value="Menu Principal" class="btn btn-azu" onclick="window.location='menu_hospital.php'" tabindex="12"/>
</div>
</div>
</body>
</html>
<?php
}else{
echo
"<script type='text/javascript'>
alert('Usted no esta logueado');
window.location='index1.php';
</script>";
}
?>
alta_consulta2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
session_start();
require ("conecta.php");
$id = $_POST['ClaveId'];
$peticion = "SELECT concat(nombre,' ',apellido) as nombre,fec_nac from paciente where ced = '$id' ";
$respuesta = mysqli_query($conectado,$peticion);
$registros = mysqli_fetch_object($respuesta);
$dato = mysqli_fetch_assoc($respuesta);
$_SESSION["pasofecha"]=$dato["fec_nac"];
$datos = $registros->nombre."/".$registros->fec_nac;
echo $datos;
?>
Valora esta pregunta


0