Ver Mensaje Individual
  #7 (permalink)  
Antiguo 12/12/2010, 22:05
Avatar de soy_nicanor
soy_nicanor
 
Fecha de Ingreso: mayo-2010
Mensajes: 374
Antigüedad: 13 años, 11 meses
Puntos: 3
como usar una SESSION

lo que yo quiero es recepcionar los datos en una $_SESSION["codigo"]=$row["codigo"]; y luego saco los datos de la tabla segun el codigo.



Aqui intente aserlo pero no me funciona

Código PHP:
Ver original
  1. <?php
  2. include('busqueda.php');
  3. $link = mysql_connect("localhost", "root", "root");
  4. mysql_select_db("sistema_de_pacientes", $link);
  5. $result = mysql_query("SELECT * FROM nombre_codigo WHERE nombres LIKE '%$buscar%' ORDER BY nombres", $link);
  6. if ($row = mysql_fetch_array($result))
  7. {
  8. $_SESSION["codigo"]=$row["codigo"];
  9. echo '<table width="400" cellspacing="0" cellpadding="3" align="center"';
  10. //Mostramos los nombres de las tablas
  11. echo "<tr>";
  12. echo "<td>"."<strong>CODIGO</strong>"."</td>";
  13. echo "<td>"."<strong>NOMBRE</strong>"."</td>";
  14. echo "<td>"."<strong>APELLIDOS</strong>"."</td>";
  15. echo "<td>"."<strong>DNI</strong>"."</td>";
  16. echo "</tr>";
  17. do {
  18.             echo "<tr>";
  19.             echo '<td><a href="cliente.php?='.$row["codigo"].'?"><font size="2" color="#0000FF">'.$row["codigo"].'</a></font></td>';
  20.             echo "<td>".$row["nombres"]."</td>";
  21.             echo "<td>".$row["apellidos"]."</td>";  
  22.             echo "<td>".$row["dni"]."</td>";
  23.             echo "</tr>";
  24.     } while ($row = mysql_fetch_array($result));
  25. echo "</table>";
  26. }
  27. else
  28. {
  29. echo "¡ No se ha encontrado ningún registro !";
  30. }
  31. ?>



Código PHP:
Ver original
  1. <?
  2. $link = mysql_connect("localhost", "root", "root");
  3.     mysql_select_db("sistema_de_pacientes", $link);
  4.    
  5. $codigo = $_GET['codigo'];
  6. $query = mysql_query("SELECT * FROM datos_paciente WHERE codigo='$codigo'") or die (mysql_error());
  7. $totEmp = mysql_num_rows($query);
  8.  
  9. if ($totEmp> 0)
  10. {
  11. while ($rowEmp = mysql_fetch_assoc($resEmp))
  12. {
  13. echo "Nombre: ".$rowEmp['codigo']."<br><br>";
  14.  }
  15. }
  16. ?>