Foros del Web » Programando para Internet » PHP »

Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a otra pagina

Estas en el tema de Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a otra pagina en el foro de PHP en Foros del Web. Hola a todos, es la primera vez que escribo en este foro. El problema que tengo es como estoy haciendo un pequeño proyecto familiar, estoy ...
  #1 (permalink)  
Antiguo 20/06/2011, 09:47
 
Fecha de Ingreso: junio-2011
Mensajes: 6
Antigüedad: 12 años, 9 meses
Puntos: 0
Pregunta Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a otra pagina

Hola a todos, es la primera vez que escribo en este foro.

El problema que tengo es como estoy haciendo un pequeño proyecto familiar, estoy haciendo una bd de un consultorio, pero me surgio una duda que si puedo hacer una búsqueda en la misma pagina, me muestre el resultado y al momento de seleccionar cual paciente quiero modificar, se pasen todos los parámetros del que seleccione a otro php llamado "modifica.php", bueno, pongo el codigo para que me entiendan mejor

Codigo del archivo "modificar.php"

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Buscando...</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
Dame el nombre del paciente a buscar:
<input type="text" name="buscaPaciente" value=""/>
<br/>
<input type="submit" value="Buscar" />
<br/>
<table border="1" width="100%">
<thead>
<tr>
<th>Selector</th>
<th>Nombre Paciente</th>
<th>Edad</th>
<th>T.A.</th>
<th>Temp.</th>
<th>Peso</th>
<th>Indicacion 1</th>
<th>Indicacion 2</th>
<th>Indicacion 3</th>
<th>Medicamentos</th>
</tr>
</thead>
<?php
$paciente=isset ($_REQUEST["buscaPaciente"]) ? $_REQUEST["buscaPaciente"] : null;

if($paciente=='')
echo ("<br/>");
else{
$cnn=mysql_connect("localhost","root");
mysql_select_db("consultorio");
$sql="select * from recetasimpresion where nombre like '%$paciente%' ORDER BY nombre ASC;";

$reg=mysql_query($sql);
echo ("<br/>");
while($arreglo=mysql_fetch_array($reg)){
echo "<tr><td>";
?>
<input type="radio" name="id" value="<?php print $arreglo["id"];?>" />
<?php
echo "</td><td>";
echo $arreglo["nombre"];
echo "</td><td>";
echo ("<center>");
echo $arreglo["edad"];echo('&nbsp; años');
echo ("</center>");
echo"</td><td>";
echo ("<center>");
echo $arreglo["ta"];
echo ("</center>");
echo "</td><td>";
echo ("<center>");
echo $arreglo["temperatura"];echo('&nbsp;°C');
echo ("</center>");
echo "</td><td>";
echo ("<center>");
echo $arreglo["peso"];echo('&nbsp; Kg.');
echo ("</center>");
echo "</td><td>";
echo $arreglo["indicacion1"];echo('&nbsp;');
echo "</td><td>";
echo $arreglo["indicacion2"];echo('&nbsp;');
echo "</td><td>";
echo $arreglo["indicacion3"];echo('&nbsp;');
echo "</td><td>";
echo $arreglo["medicamento"];
echo "</td></tr>";
}
mysql_close($cnn);
}
?>
<tr><td colspan="10" align="center">
<input value="Modificar" name="submit" type="button" onclick="window.location.href = 'modifica.php';" />
</td><tr>
</table>
</form>
</body>
</html>

Habra manera de hacer eso, o es poner un Form dentro de otro form
  #2 (permalink)  
Antiguo 20/06/2011, 10:31
 
Fecha de Ingreso: febrero-2010
Mensajes: 818
Antigüedad: 14 años, 1 mes
Puntos: 55
Respuesta: Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a o

podrias hacer un link con el id del paciente haci lo recibes por get en la otra pagina

<a href='modificar_paciente.php?&id=<?php echo $id; ?>'>Modificar</a>

y en modificar_paciente.php

recibes el id con $_GET['id']
  #3 (permalink)  
Antiguo 20/06/2011, 10:31
Avatar de truman_truman  
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 1 mes
Puntos: 177
Respuesta: Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a o

En la tabla recetasimpresion debe haber un campo id que sea único y autoincrementable, cada paciente tendrá un id único, entonces ese id lo mostrás en un campo hidden:

<input name="id" type="hidden" value="<?php echo $arreglo["id"]; ?>">

al darle clic al boton este valor se envía al otro archivo, entonces lo recuperas por medio de $_POST['id'] y con es valor haces una nueva consulta, consulta la tabla autoincrementable where id = '".$_POST['id']."' ... y te mostrará los datos de ese paciente


Saludos
__________________
la la la
  #4 (permalink)  
Antiguo 20/06/2011, 11:04
 
Fecha de Ingreso: junio-2011
Mensajes: 6
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a o

Intentare las mencionadas, les comento que salio :P
  #5 (permalink)  
Antiguo 20/06/2011, 11:21
 
Fecha de Ingreso: junio-2011
Mensajes: 6
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: Buscar en la misma pagina, seleccionar elemento a modificar y enviarlo a o

Sigo recibiendo errores y no recibo los datos :S

Pongo el otro código en donde recibo la posición del id y tiene que rellenar los datos para que se entienda un poco mejor mi problema

Codigo de "modifica.php"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Receta</title>
<script>
function caps(element){
element.value = element.value.toUpperCase();
}
</script>


<link rel="stylesheet" href="css\receta.css">
</head>
<body>
<?php
// put your code here
$id=isset($_POST["id"]) ? $_POST["id"] : null;
$cnn=mysql_connect("localhost", "root");
mysql_select_db("consultorio");

$sql="select * from recetasimpresion where id=".$id;

$result=mysql_query($sql);
$arreglo=mysql_fetch_array($result);
mysql_close($cnn);
?>
<form action="cambia.php" method="post">
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="colortitulo">DATOS GENERALES DEL PACIENTE</td>
</tr>
</table>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="8%" height="24" valign="bottom" id="fuentetexto">Nombre:</td>
<td colspan="7" valign="top"><input name="nombrePaciente" type="text" id="nombrePaciente" size="100" maxlength="80" onkeyup="caps(this)" value="<?php print $arreglo["nombre"];?>"/></td>
</tr>
<tr>
<td height="49" id="fuentetexto">Edad:</td>
<td width="15%"><input name="edadPaciente" type="text" id="edadPaciente" size="3" maxlength="3" value="<?php print $arreglo["edad"];?>"/>
<font id="fuentetexto">años </font></td>
<td width="4%" align="right" id="fuentetexto">T.A.:</td>
<td width="9%"><input name="TA" type="text" id="TA" size="10" maxlength="10" value="<?php print $arreglo["ta"];?>" /></td>
<td width="12%" align="right" id="fuentetexto">Temp.:</td>
<td width="11%"><input name="tempPaciente" type="text" id="tempPaciente" size="3" maxlength="3" value="<?php print $arreglo["temperatura"];?>"/>
<font id="fuentetexto">°C </font></td>
<td width="26%" align="right" id="fuentetexto">Peso:</td>
<td width="15%"><input name="pesoPaciente" type="text" id="pesoPaciente" size="4" maxlength="4" value="<?php print $arreglo["peso"];?>"/>
<font id="fuentetexto">Kilos</font></td>
</tr>
<tr>
<td colspan="8" id="fuentetexto">Medicamentos:</td>
</tr>
<tr>
<td height="225" colspan="8"><center><textarea name="medicina" cols="80" rows="13" id="medicina" onkeyup="caps(this)" value="<?php print $arreglo["medicamento"];?>"></textarea></center></td>
</tr>
</table>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="colortitulo" class="fuentetexto">INDICACIONES</td>
</tr>
</table>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6%" height="28" align="center" id="fuentetexto">1.-</td>
<td width="94%"><label for="indicacion1"></label>
<input name="indicacion1" type="text" id="indicacion1" size="100" onkeyup="caps(this)" value="<?php print $arreglo["indicacion1"];?>"/></td>
</tr>
<tr>
<td height="31" align="center" id="fuentetexto">2.-</td>
<td><input name="indicacion2" type="text" id="indicacion2" size="100" onkeyup="caps(this)" value="<?php print $arreglo["indicacion2"];?>"/></td>
</tr>
<tr>
<td height="28" align="center" id="fuentetexto">3.-</td>
<td><input name="indicacion3" type="text" id="indicacion3" size="100" onkeyup="caps(this)" value="<?php print $arreglo["indicacion3"];?>"/></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><center><input id="botontexto"type="submit" value="Generar Receta para Imprimir" /></center></td>
<input type="hidden" name="id"
value="<?php print $id?>"/>
</tr>
</table>
</form>
</body>
</html>

Etiquetas: busquedas, modificar, php_self
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:45.