Foros del Web » Programando para Internet » PHP »

PHP OO Filtro/busqueda PHP

Estas en el tema de Filtro/busqueda PHP en el foro de PHP en Foros del Web. Un saludo a toda la gente del foro. Tengo un problema para realizar una búsqueda en una tabla dinámica creada con dreamweaver. Sencillamente no responde ...
  #1 (permalink)  
Antiguo 17/02/2011, 06:41
 
Fecha de Ingreso: abril-2010
Mensajes: 52
Antigüedad: 13 años, 11 meses
Puntos: 0
Filtro/busqueda PHP

Un saludo a toda la gente del foro.

Tengo un problema para realizar una búsqueda en una tabla dinámica creada con dreamweaver.
Sencillamente no responde a la búsqueda y tampoco me devuelve un error. No reacciona y estoy bloqueado en este punto.

Mi agradecimiento a quien pueda echarme un cable.

El form para recoger la palabra de búsqueda es el siguiente:

<form action="paintball.php" method="get" name="form1" id="form1">
<input name="busqueda" type="text" id="busqueda" value="<?php echo $_GET['busqueda']; ?>" />
<input name="btnBuscar" type="submit" id="btnBuscar" value="Buscar!" />
</form>


Los filtros que he creado:


if($_REQUEST["btnBuscar"]!="" && $_REQUEST["busqueda"]!="")
{

if(is_numeric($_REQUEST["busqueda"]))
$filtro="id=". $_REQUEST["busqueda"];
else
$filtro=" provincia like '%".$_REQUEST["busqueda"]."%' or precio like '%".$_REQUEST["busqueda"]."%'";
$mensaje=$filtro;

}else
{
$mensaje="<font color='red'>Escriba Algo</font>";
}



I los detalles de la tabla son:

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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

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_cnxaventuras, $cnxaventuras);
$query_rsCategorias = "SELECT * FROM provincia ORDER BY provincia ASC";
$rsCategorias = mysql_query($query_rsCategorias, $cnxaventuras) or die(mysql_error());
$row_rsCategorias = mysql_fetch_assoc($rsCategorias);
$totalRows_rsCategorias = mysql_num_rows($rsCategorias);

mysql_select_db($database_cnxaventuras, $cnxaventuras);
$query_rsProductos = "SELECT * FROM producto ORDER BY precio ASC";
$rsProductos = mysql_query($query_rsProductos, $cnxaventuras) or die(mysql_error());
$row_rsProductos = mysql_fetch_assoc($rsProductos);
$totalRows_rsProductos = mysql_num_rows($rsProductos);

$maxRows_rsProductos = 3;
$pageNum_rsProductos = 0;
if (isset($_GET['pageNum_rsProductos'])) {
$pageNum_rsProductos = $_GET['pageNum_rsProductos'];
}
$startRow_rsProductos = $pageNum_rsProductos * $maxRows_rsProductos;

$colname_rsProductos = "-1";
if (isset($_POST['listaProvincia'])) {
$colname_rsProductos = $_POST['listaProvincia'];
}
mysql_select_db($database_cnxaventuras, $cnxaventuras);
$query_rsProductos = sprintf("SELECT * FROM producto WHERE familia = 'paintball' ORDER BY precio ASC", GetSQLValueString($colname_rsProductos, "text"));
$query_limit_rsProductos = sprintf("%s LIMIT %d, %d", $query_rsProductos, $startRow_rsProductos, $maxRows_rsProductos);
$rsProductos = mysql_query($query_limit_rsProductos, $cnxaventuras) or die(mysql_error());
$row_rsProductos = mysql_fetch_assoc($rsProductos);


if (isset($_GET['totalRows_rsProductos'])) {
$totalRows_rsProductos = $_GET['totalRows_rsProductos'];
} else {
$all_rsProductos = mysql_query($query_rsProductos);
$totalRows_rsProductos = mysql_num_rows($all_rsProductos);
}
$totalPages_rsProductos = ceil($totalRows_rsProductos/$maxRows_rsProductos)-1;

$queryString_rsProductos = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsProductos") == false &&
stristr($param, "totalRows_rsProductos") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsProductos = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsProductos = sprintf("&totalRows_rsProductos=%d%s", $totalRows_rsProductos, $queryString_rsProductos);



Gracias de antemano

Etiquetas: Ninguno
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 00:42.