Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/09/2010, 07:47
Avatar de oscarios
oscarios
 
Fecha de Ingreso: septiembre-2004
Mensajes: 186
Antigüedad: 19 años, 7 meses
Puntos: 2
buscador con varios parametros

hola buenos dias, hoy acudo a ustedes para pedir su ayuda con algo sencillo creo!! tengo una pagina de busqueda y respuesta con 4 parametros de busqueda en dreamweaver, todo funciona ok pero cuando dejo uno de los parametros en blanco no me da resultados, me pasa algo ahi con el like and, bueno de php y sql no se soy dreamweaver dependiente,,,,,,,,mil gracias por su valiosa ayuda...

Código PHP:
Ver original
  1. <?php
  2. if(!isset($_GET['field'])){
  3.  $_GET['field']='Id';
  4. }
  5. if (!function_exists("GetSQLValueString")) {
  6. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  7. {
  8.   if (PHP_VERSION < 6) {
  9.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  10.   }
  11.  
  12.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  13.  
  14.   switch ($theType) {
  15.     case "text":
  16.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  17.       break;    
  18.     case "long":
  19.     case "int":
  20.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  21.       break;
  22.     case "double":
  23.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  24.       break;
  25.     case "date":
  26.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  27.       break;
  28.     case "defined":
  29.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  30.       break;
  31.   }
  32.   return $theValue;
  33. }
  34. }
  35.  
  36. $currentPage = $_SERVER["PHP_SELF"];
  37.  
  38. $maxRows_Recordset1 = 10;
  39. $pageNum_Recordset1 = 0;
  40. if (isset($_GET['pageNum_Recordset1'])) {
  41.   $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
  42. }
  43. $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
  44.  
  45. $colname_Recordset1 = "-1";
  46. if (isset($_GET['ciudad'])) {
  47.   $colname_Recordset1 = $_GET['ciudad'];
  48. }
  49. $colpara_Recordset1 = "-1";
  50. if (isset($_GET['zona'])) {
  51.   $colpara_Recordset1 = $_GET['zona'];
  52. }
  53. $coltype_Recordset1 = "-1";
  54. if (isset($_GET['tipo'])) {
  55.   $coltype_Recordset1 = $_GET['tipo'];
  56. }
  57. $colrang_Recordset1 = "-1";
  58. if (isset($_GET['rango'])) {
  59.   $colrang_Recordset1 = $_GET['rango'];
  60. }
  61. mysql_select_db($database_conbanca, $conbanca);
  62. $query_Recordset1 = sprintf("SELECT inmuebles.id, inmuebles.foto_a, inmuebles.foto_b, inmuebles.foto_c, inmuebles.foto_d, inmuebles.foto_e, inmuebles.foto_f, inmuebles.ciudad, inmuebles.zona, inmuebles.barrio, inmuebles.direccion, inmuebles.tipo, inmuebles.valor, inmuebles.rango, inmuebles.area, inmuebles.habitaciones, inmuebles.codigo_inm, inmuebles.obs FROM inmuebles WHERE inmuebles.ciudad LIKE %s  AND inmuebles.zona LIKE %s  AND inmuebles.tipo LIKE %s  AND inmuebles.rango LIKE %s ORDER BY " .$_GET['field']." ".$_GET['order'], GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colpara_Recordset1, "text"),GetSQLValueString($coltype_Recordset1, "text"),GetSQLValueString($colrang_Recordset1, "text"));
  63. $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
  64. $Recordset1 = mysql_query($query_limit_Recordset1, $conbanca) or die(mysql_error());
  65. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  66.  
  67. if (isset($_GET['totalRows_Recordset1'])) {
  68.   $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
  69. } else {
  70.   $all_Recordset1 = mysql_query($query_Recordset1);
  71.   $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
  72. }
  73. $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
  74.  
  75. $queryString_Recordset1 = "";
  76. if (!empty($_SERVER['QUERY_STRING'])) {
  77.   $params = explode("&", $_SERVER['QUERY_STRING']);
  78.   $newParams = array();
  79.   foreach ($params as $param) {
  80.     if (stristr($param, "pageNum_Recordset1") == false &&
  81.         stristr($param, "totalRows_Recordset1") == false) {
  82.       array_push($newParams, $param);
  83.     }
  84.   }
  85.   if (count($newParams) != 0) {
  86.     $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
  87.   }
  88. }
  89. $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
  90. ?>
__________________
oscariosdw