Foros del Web » Programando para Internet » PHP »

Como realizar un filtro de busqueda

Estas en el tema de Como realizar un filtro de busqueda en el foro de PHP en Foros del Web. Buenas miren, necesito con suma urgencia crear un buscador de productos pero por categorias, miren esta pagina por favor! http://interwattheaters.com/listas_s...o_cartucho.php Si se dan cuenta he ...
  #1 (permalink)  
Antiguo 26/05/2008, 15:14
Avatar de xxrandyxx  
Fecha de Ingreso: abril-2008
Ubicación: En mi casa
Mensajes: 143
Antigüedad: 16 años
Puntos: 2
Como realizar un filtro de busqueda

Buenas miren, necesito con suma urgencia crear un buscador de productos pero por categorias, miren esta pagina por favor!

http://interwattheaters.com/listas_s...o_cartucho.php

Si se dan cuenta he tratado de filtrar por diametro, osea escojer 9,5 o 9,6 y me salgan todas las categorias que tengan ese filtro, tambien busco filtrar por largo y por todo lo que ven ahi, si no fuera mucha molestia les pediria que me hagan algo similar, la verdad no se como hacer para que busque.

Necesito si pueden que me armen el codigo lo mas simple posible y el form tambien el mas simple posible y yo tratare de entenderlo, porfis ya que esa web la hice con dreamweaver y es mas facil

POR FAVOR AYUDAAAAAAAAAA!
  #2 (permalink)  
Antiguo 26/05/2008, 15:43
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 1 mes
Puntos: 52
Respuesta: Por favor ayuda urgente

que quieres hacer un buscador con esos cuatro selects???

para xxrandyxx aqui no creo que haya lobos, hay gente que esta aprendiendo y verdaderos maestro del php que ayundan sin pedir nada por hacerlo. y eso no tiene precio.
Y por cierto, tampoco estamos en el foro para hacerle todo el codigo a todo el mundo. el php lo bueno que tiene es que es facil de entender y aprender.
Un saludo

Última edición por jaronu; 26/05/2008 a las 15:48
  #3 (permalink)  
Antiguo 26/05/2008, 15:47
Avatar de xxrandyxx  
Fecha de Ingreso: abril-2008
Ubicación: En mi casa
Mensajes: 143
Antigüedad: 16 años
Puntos: 2
Respuesta: Por favor ayuda urgente

asi es! mas que nada un flitro, que solo me vote los datos ya pre puestos!
  #4 (permalink)  
Antiguo 26/05/2008, 15:52
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 1 mes
Puntos: 52
Respuesta: Por favor ayuda urgente

imagino que esos cuatro selects estan ya en el form

postealo por favor

Y algo fundamental, como almacenas esos datos, en que BD de MySQL y su estructura, a si seria mas facil
  #5 (permalink)  
Antiguo 26/05/2008, 15:54
Avatar de xxrandyxx  
Fecha de Ingreso: abril-2008
Ubicación: En mi casa
Mensajes: 143
Antigüedad: 16 años
Puntos: 2
Respuesta: Por favor ayuda urgente

Código:
<?php require_once('../Connections/heaterco_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_heaterco_db, $heaterco_db);
$query_rs_car = "SELECT * FROM resistencia_cartucho ORDER BY diametro DESC";
$rs_car = mysql_query($query_rs_car, $heaterco_db) or die(mysql_error());
$row_rs_car = mysql_fetch_assoc($rs_car);
$totalRows_rs_car = mysql_num_rows($rs_car);

$select=$_GET[select];
$select1 = $row_rs_car['voltaje']

?>



<!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>Documento sin t&iacute;tulo</title>
<link href="estilos/stilos.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','300','height','95','src','../peliculas/logo','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','wmode','transparent','menu','false','movie','../peliculas/logo' ); //end AC code
      </script>
        <noscript>
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="300" height="95">
          <param name="movie" value="../peliculas/logo.swf" />
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <param name="menu" value="false" />
          <embed src="../peliculas/logo.swf" width="300" height="95" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" menu="false"></embed>
        </object>
        </noscript>        </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table></td>
      </tr>
      <tr>
        <td align="center" class="text1">RESISTENCIAS TIPO CARTUCHO</td>
      </tr>
      <tr>
        <td align="center" class="text1">Lista de productos en Stock</td>
      </tr>
      <tr>
        <td align="center"><form name="form" id="form">
          <label></label>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td align="center"><label>
                <select name="select" id="select">
                  <option>Diametro del Tubo</option>
                </select>
              </label>
                <label>
                <select name="select2" id="select2">
                  <option>Largo</option>
                </select>
                </label>
                <label>
                <select name="select3" id="select3">
                  <option>Potencia</option>
                </select>
                </label>
                <label>
                <select name="select4" id="select4">
                  <option>Voltaje</option>
                </select>
                </label></td>
            </tr>
          </table>
          <br />
          <label></label>
        </form>
        </td>
      </tr>
      <tr>
        <td align="center"></td>
      </tr>
      <tr>
        <td><table width="800" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="70" height="20" align="center" class="text3">CODIGO</td>
            <td width="100" height="20" align="center" class="text3"><span class="text3">&Oslash;</span> DEL TUBO</td>
            <td width="100" height="20" align="center" class="text3">LARGO</td>
            <td width="100" height="20" align="center" class="text3">POTENCIA</td>
            <td width="100" height="20" align="center" class="text3">VOLTAJE</td>
            <td width="130" height="20" align="center" class="text3">LARGO D' CABLE</td>
            <td width="100" height="20" align="center" class="text3">PRECIO</td>
            <td width="100" align="center" class="text3">Ver Producto</td>
          </tr>
          
        </table>
          <table >
            <tr>
              <?php
$rs_car_endRow = 0;
$rs_car_columns = 1; // number of columns
$rs_car_hloopRow1 = 0; // first row flag
do {
    if($rs_car_endRow == 0  && $rs_car_hloopRow1++ != 0) echo "<tr>";
   ?>
              <td><table width="800" border="0" cellpadding="0" cellspacing="0" class="text4">
                  <tr>
                    <td width="70" align="center"><?php echo $row_rs_car['item']; ?></td>
                    <td width="100" align="center"><?php echo $row_rs_car['diametro']; ?> mm</td>
                    <td width="100" align="center"><?php echo $row_rs_car['largo']; ?> mm</td>
                    <td width="100" align="center"><?php echo $row_rs_car['potencia']; ?> w</td>
                    <td width="100" align="center"><?php echo $row_rs_car['voltaje']; ?> v</td>
                    <td width="130" align="center"><?php echo $row_rs_car['largo_cable']; ?> cm</td>
                    <td width="100" align="center">S/ .<?php echo $row_rs_car['precio']; ?></td>
                    <td width="100" align="center"><a href="detalle_stock.php?item=<?php echo $row_rs_car['item']; ?>">Ver</a> </td>
                  </tr>
              </table></td>
              <?php  $rs_car_endRow++;
if($rs_car_endRow >= $rs_car_columns) {
  ?>
            </tr>
            <?php
 $rs_car_endRow = 0;
  }
} while ($row_rs_car = mysql_fetch_assoc($rs_car));
if($rs_car_endRow != 0) {
while ($rs_car_endRow < $rs_car_columns) {
    echo("<td>&nbsp;</td>");
    $rs_car_endRow++;
}
echo("</tr>");
}?>
                    </table></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><a href="menu.php">Regresar al Menu de Productos Generales</a></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rs_car);
?>
  #6 (permalink)  
Antiguo 26/05/2008, 15:55
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Por favor ayuda urgente

Hola xxrandyxx,

Primero te pido que uses títulos más descriptivos en tus temas, así invitas a más gente a participar en tus temas.

Por otro lado aquí el foro está para ayudar, no para hacer el trabajo por ti, si no sabes mucho de PHP te recomiendo que postees en el foro de Ofertas de Empleo, estoy seguro que alguien podrá realizar el código por una remuneración económica.

Saludos.
  #7 (permalink)  
Antiguo 26/05/2008, 15:58
Avatar de xxrandyxx  
Fecha de Ingreso: abril-2008
Ubicación: En mi casa
Mensajes: 143
Antigüedad: 16 años
Puntos: 2
Respuesta: Como realizar un filtro de busqueda

El chiste no es pagar, estamos todos para ayudarnos, yo se action script, y si veo alguien que necesita ayuda le doy una ayuda, no soy sinverguenza =P trato de aprender
  #8 (permalink)  
Antiguo 26/05/2008, 16:06
Avatar de oso96_2000  
Fecha de Ingreso: junio-2002
Ubicación: Distrito Federal
Mensajes: 558
Antigüedad: 21 años, 10 meses
Puntos: 35
Respuesta: Como realizar un filtro de busqueda

Pero hay formas de pedir las cosas, y el segundo mensaje que habías puesto (que borraste o borraron, no lo se ni interesa), al menos en lo personal me quita todas las ganas que hubiera tenido de ayudarte =P

Pero en fin, yo repito la pregunta de jaronu: ¿como tienes guardados los datos el la BD? También pon un botón para enviar el formulario, asi no podemos ver como funciona.

Ahora bien, otra cosa importante es: ¿que tan bien manejas la base de datos? Digo, si quieres aprender para ir diciéndote mas o menos como se ahce, no pidas que te lo hagan.. para eso, como dijo GatorV, esta el foro de Ofertas de Empleo.
__________________
Sin Ideas
  #9 (permalink)  
Antiguo 26/05/2008, 16:07
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Como realizar un filtro de busqueda

Como dices el foro es para aprender, tu publicaste en tu primer tema, que quieres que alguien te haga las cosas y no expones lo que llevas.

Si te interesa aprender lee sobre bases de datos hay muchísima documentación al respecto, para hacer los filtros que quieres debes de usar mysql_query, y filtrar por SQL usando la instrucción WHERE.

Saludos.
  #10 (permalink)  
Antiguo 26/05/2008, 16:49
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 1 mes
Puntos: 52
Respuesta: Como realizar un filtro de busqueda

pues añadiendo a tu query una clausula WHERE

Código PHP:

$diametro 
$_POST ['select']; //recuperas el valor del check diametro del tubo haz lo mismo con las demas y añadeña al query separandolas con un AND
$query_rs_car "SELECT * FROM resistencia_cartucho WHERE Diametro_del_Tubo = '$diametro' ORDER BY diametro DESC"
Esta es la idea
un saludo
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 08:18.