Ver Mensaje Individual
  #4 (permalink)  
Antiguo 09/02/2011, 20:43
Miguel_Mendez
 
Fecha de Ingreso: noviembre-2009
Mensajes: 17
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Dreamweaver consulta de usuario a tabla de BD

Hola Emanuel

Lo primero que hay que hacer es crear un campo de busqueda con un input llamado por ejemplo usuario

Código HTML:
Ver original
  1. <form id="form1" name="form1" method="post" action="">
  2.   <label for="nombre"></label>
  3.   <input name="nombre" type="text" id="nombre" />
  4.   <input type="submit" name="button" id="button" value="Submit" />
  5. </form>

una vez hecho esto creamos un recorset en DW al campo en que se va a hacer la busqueda por ejemplo selecciono la tabla profesores y busco en el campo usuario. Seleccionamos un filtro con el nombre del campo del formulario nombre y en Form Variable seleccionamos el campo usuario




Ahora abrimos el panel de Bindings y arrastramos el campo nombre como se muestra en la imagen.


lo siguiente es las propiedades del form que en la imagen de abajo se muestra



y como paso ultimo podemos agregar un Repet Region para que muestre si hay mas resultados con el mismo nombre





el codigo quedo algo asi

Código PHP:
Ver original
  1. <?php require_once('Connections/conexion.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $colname_Recordset1 = "-1";
  35. if (isset($_POST['nombre'])) {
  36.   $colname_Recordset1 = $_POST['nombre'];
  37. }
  38. mysql_select_db($database_conexion, $conexion);
  39. $query_Recordset1 = sprintf("SELECT * FROM profesores WHERE nombre = %s", GetSQLValueString($colname_Recordset1, "text"));
  40. $Recordset1 = mysql_query($query_Recordset1, $conexion) or die(mysql_error());
  41. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  42. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  43. ?>
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  45. <html xmlns="http://www.w3.org/1999/xhtml">
  46. <head>
  47. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  48. <title>Untitled Document</title>
  49. </head>
  50.  
  51. <body>
  52. <form id="form1" name="form1" method="post" action="Untitled-1.php">
  53.   <label for="nombre"></label>
  54.   <input name="nombre" type="text" id="nombre" />
  55.   <input type="submit" name="button" id="button" value="Submit" />
  56. </form>
  57. <?php echo $row_Recordset1['nombre']; ?>
  58. </body>
  59. </html>
  60. <?php
  61. mysql_free_result($Recordset1);
  62. ?>

y eso es todo

espero haberte ayudado

saludos