Ver Mensaje Individual
  #5 (permalink)  
Antiguo 24/11/2013, 07:49
Avatar de manyblue
manyblue
 
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Problema buscador php y mysql

Ante todo MUCHISIMAS GRACIAS A FOROS DEL WEB, siempre me respondeis, me habéis ayudado mogollon y esto desde el 2008 que me di de alte, asi que lo dicho, animo y gracias.


Bueno me he tranquilizado, sentado, pensar y actuar con calma y viendo los detalles, problema solucionado aquí dejo el código:


BUSCADORES:


Código HTML:

 <form action="noticias_buscador_categorias.php" method="get" id="form1">
 <label for="FBuscador"></label>
 <input type="text" name="FBuscador" id="FBuscador" />
 <input type="submit" name="button" id="button" value="Buscar" />
 </form>



  <form action="noticias_buscador_titulo.php" method="get" id="form2">
  <label for="FBuscador2"></label>
  <input type="text" name="FBuscador2" id="FBuscador2" />
  <input type="submit" name="button2" id="button2" value="Buscar" />
  </form>

Para: "tbl_categ_noticias" y "tbl_noticias"


BUSCADOR POR CATEGORÍA DE LA NOTICIA (Solo pongo este para no abultar, el de noticias se hace igual cambiendo el "FBuacador" por "FBuscador2"):


Código PHP:

<?php require_once('../Connections/conex_db_teldetv.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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;
}
}
$maxRows_ConsultaNotias 20;
$pageNum_ConsultaNotias 0;
if (isset(
$_GET['pageNum_ConsultaNotias'])) {
  
$pageNum_ConsultaNotias $_GET['pageNum_ConsultaNotias'];
}
$startRow_ConsultaNotias $pageNum_ConsultaNotias $maxRows_ConsultaNotias;
$varNoticias_categorias "0";
if (isset(
$_GET["FBuscador"])) {
  
$varNoticias_categorias $_GET["FBuscador"];
}
mysql_select_db($database_conex_db_teldetv$conex_db_teldetv);
$query_ConsultaNotias "SELECT tbl_categ_noticias.categ_noticia, tbl_categ_noticias.descripcion_noticia, tbl_categ_noticias.imagen_categ_noticia, tbl_noticias.id_categ_noticia, tbl_noticias.id_noticia, tbl_noticias.titulo_noticia, tbl_noticias.resumen_noticia, tbl_noticias.texto_noticia, tbl_noticias.imagen_1_noticia, tbl_noticias.imagen_2_noticia, tbl_noticias.fecha_noticia, tbl_noticias.activo_noticia, tbl_noticias.rtmp_noticia, tbl_noticias.http_flash_noticia, tbl_noticias.http_ios_noticia, tbl_noticias.rtsp_noticia, tbl_noticias.codigo_1_noticia, tbl_noticias.codigo_2_noticia FROM tbl_noticias INNER JOIN tbl_categ_noticias ON tbl_categ_noticias.id_categ_noticia = tbl_noticias.id_categ_noticia WHERE tbl_categ_noticias.categ_noticia LIKE '%".$varNoticias_categorias."%'";
$query_limit_ConsultaNotias sprintf("%s LIMIT %d, %d"$query_ConsultaNotias$startRow_ConsultaNotias$maxRows_ConsultaNotias);
$ConsultaNotias mysql_query($query_limit_ConsultaNotias$conex_db_teldetv) or die(mysql_error());
$row_ConsultaNotias mysql_fetch_assoc($ConsultaNotias);
if (isset(
$_GET['totalRows_ConsultaNotias'])) {
  
$totalRows_ConsultaNotias $_GET['totalRows_ConsultaNotias'];
} else {
  
$all_ConsultaNotias mysql_query($query_ConsultaNotias);
  
$totalRows_ConsultaNotias mysql_num_rows($all_ConsultaNotias);
}
$totalPages_ConsultaNotias ceil($totalRows_ConsultaNotias/$maxRows_ConsultaNotias)-1;
$queryString_ConsultaNotias "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_ConsultaNotias") == false && 
        
stristr($param"totalRows_ConsultaNotias") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_ConsultaNotias "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_ConsultaNotias sprintf("&totalRows_ConsultaNotias=%d%s"$totalRows_ConsultaNotias$queryString_ConsultaNotias);
?>
]


Nada, lo dicho, muchas gracias por vuestras molestias.
Un saludo: Manyblue