Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/12/2012, 14:02
ilem
 
Fecha de Ingreso: abril-2007
Mensajes: 6
Antigüedad: 17 años, 1 mes
Puntos: 0
Mostrar datos de tabla

Hola buenas. Estoy empezando con php y me parece fascinante, pero como todo al empezar, pues eso... al grano.
Estoy armando un pequeño proyecto para un control de pacientes. En cada visita guardo a traves de un formulario dicha visita con campos del tipo paciente, motivo, tratamiento efectuado, etc.
Pues bien, en el apartado de la ficha de los clientes quisiera que me mostrara las últimas visitas y estoy hecho un lio...he probado varias formas pero no funciona. Agradecería que le hecharais un vistazo a ver donde me falla (que supongo que es en muchos sitios, jejeje)El codigo es el siguiente:
<?php
include "funciones.php";
$id=$_GET['id_paciente'];
$conex=conectar();
$sql="select * from paciente where id_paciente=".$id;
if(!$result=mysql_query($sql, $conex))
{
?>
<script>
alert ("No se ha podido realizar la consulta");
document.location=('pac_ficha.php');
</script>
<?php


echo mysql_error($conex);
exit;
}
$contador=0;
$array_pacientes=mysql_fetch_array($result);
$id=$array_pacientes[0];
$val=$array_pacientes[3];
$anno=substr($val, 0, 4);
$mes=substr($val, 5, 2);
$dia=substr($val, 8, 2);



echo" <form name='ficha' action='' method='post' enctype='multipart/form-data'>";
echo"<table width='700' align='center' class='tabla' background='images/fondoficha.jpg'>";
echo"<tr>";
echo"<td align='center'><h3>Datos Personales</h3></td>";
echo"<td><a href=pac_modificar.php?id_paciente=".$array_pacien tes['id_paciente'].">Modificar Paciente</a>&nbsp;<font color='red' size='-1' style='padding-left:125px;'><a href='act_est.php'>Volver</a></font> </td>";
echo"</tr>";
echo"<tr>";
echo"<td>Nombre</td>";
echo"<td><input type='text' name='nombre' size='40' value='$array_pacientes[1]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Apellidos</td>";
echo"<td><input type='text' name='apellido' size='40' value='$array_pacientes[2]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Fecha de Nacimiento</td>";
echo"<td><input type='text' name='input5' value='".$dia."-".$mes."-".$anno."' />";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>Sexo</td>";
echo"<td>";
echo"<input type='text' name='sexo' value='$array_pacientes[4]'>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>Telefono</td>";
echo"<td><input type='text' name='telefono' size='20' value='$array_pacientes[5]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Direcci&oacute;n</td>";
echo"<td><input type='text' name='direccion' size='40' value='$array_pacientes[6]'/></textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Email</td>";
echo"<td><input type='text' name='email' size='40' value='$array_pacientes[7]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td >Ciudad</td>";
echo"<td ><input type='text' name='ciudad' size='15' value='$array_pacientes[9]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Provincia</td>";
echo"<td><input type='text' name='provincia' size='15' value='$array_pacientes[10]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Estado Civil</td>";
echo"<td>";
echo"<input type='text' name='estciv' value='$array_pacientes[11]'>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>Ocupacion</td>";
echo"<td><input type='text' name='ocupacion' size='20' value='$array_pacientes[13]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Antecedentes Sanitarios</td>";
echo"<td><textarea rows='2' name='antecedentes' cols='40'>$array_pacientes[12]</textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Alergico a</td>";
echo"<td><textarea rows='2' name='alergico' cols='40'>$array_pacientes[14]</textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Diagnostico propio</td>";
echo"<td><textarea rows='2' name='diapro' cols='40'>$array_pacientes[15]</textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Consejos</td>";
echo"<td><textarea rows='2' name='consejos' cols='40'>$array_pacientes[16]</textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Dietas</td>";
echo"<td><textarea rows='2' name='dietas' cols='40'>$array_pacientes[17]</textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Ejercicios</td>";
echo"<td><textarea rows='2' name='ejercicios' cols='40'>$array_pacientes[18]</textarea></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Peso</td>";
echo"<td><input type='text' name='peso' size='5' value='$array_pacientes[19]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Talla</td>";
echo"<td><input type='text' name='talla' size='5' value='$array_pacientes[20]'/></td>";
echo"</tr>";
echo"</table>";
echo"</form>";
echo"<br>";



$id2=$_GET['id_historial'];
$sql2="select id_historial,nom_pac,fec_gen_hist,motivo,tratamien to FROM historial";
if(!$result2=mysql_query($sql2, $conex))
{
?>
<script>
alert ("No se ha podido realizar la consulta");
document.location=('pac_ficha.php');
</script>
<?php


echo mysql_error($conex);
exit;
}
$contador2=0;
$array_historial=mysql_fetch_array($result2);
$id=$array_historial[0];
$val=$array_historial[2];
$anno=substr($val, 0, 4);
$mes=substr($val, 5, 2);
$dia=substr($val, 8, 2);
$nombre=$array_historial[1];

if ($nombre=$array_pacientes[1]){

echo"<table width='700' align='center' class='tabla' background='images/fondoficha.jpg'>";
echo"<tr>";
echo"<td align='center'><h3>Ultimas visitas</h3></td>";
echo"<tr>";
echo"<td>Fecha</td>";
echo"<td>Motivo</td>";
echo"<td>Tratamiento</td>";
echo"</tr>";
echo"<tr>";
echo"<td><input type='text' name='fecha' value='".$dia."-".$mes."-".$anno."' /></td>";
echo"<td><input type='text' name='motivo' size='40' value='$array_historial[3]'/></td>";
echo"<td><input type='text' name='tratamiento' size='40' value='$array_historial[4]'/></td>";
echo"</tr>";
echo"</table>";
mysql_close($conex);
echo"<br>";
echo"<br>";
}
?>