Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/08/2013, 10:42
elizalva72
 
Fecha de Ingreso: agosto-2013
Mensajes: 2
Antigüedad: 10 años, 8 meses
Puntos: 0
Pregunta Dessarrollar buscador interno php mysql

Estoy intentando hacer un buscador interno y segui las instrucciones que el colaborador "juaniquillo" en este link ofrece:
http://www.forosdelweb.com/f17/por-favor-ayuda-con-form-variable-455687/

Mi problema es que no se como resolver la página donde se van a mostrar los resultados. Tengo dos páginas hechas una es index.php (que es donde hago la consulta) y la otra es buscador.php (que es donde se muestran los resultados).

La programación de la primera es esta:

<?php require_once('../Connections/fidprensa.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;
}
}

$colname_Recordset1 = "-1";
if (isset($_POST['Introduce una palabra'])) {
$colname_Recordset1 = $_POST['Introduce una palabra'];
}
mysql_select_db($database_fidprensa, $fidprensa);
$query_Recordset1 = sprintf("SELECT descripcion FROM archivos WHERE descripcion LIKE %s", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"));
$Recordset1 = mysql_query($query_Recordset1, $fidprensa) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fid prensa</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<style type="text/css">
#paquetes {
position: absolute;
left: 226px;
top: 437px;
width: 775px;
height: 24px;
z-index: 1;
border-top-color: #dcab4c;
border-bottom-color: #dcab4c;
}
</style>
<!--<style type="text/css">
@media screen and (max-width:650px){
#col1,#col2{
width:97.5%;
}
#col2{background-image:url(logo.jpg);}
}
</style>
-->
</head>



<body>

<section id="wrapper">
<!-- encabezado -->

<img src="images/logo.png" width="100%" />
<!--contenido principal -->
<article>
<p style="color:#dcab4c" align="right">Registro</p>
<p style="color:#dcab4c" align="right">Entrar</p>
<h1 style="color:#dcab4c" align="center">&nbsp;</h1>

<div id="camposBuscadorPalabra">
<fieldset>

<legend style="color:#dcab4c">BUSCADOR</legend>

<form id="fpalabra" name="fpalabra" method="get" action="buscador.php">
<table width="150" border="0" align="center">
<tr>
<td colspan="2"><input name="palabra" type="text" class="camposBuscador" id="palabra" size="20" /></td>
</tr>
<tr>
<td width="101">&nbsp;</td>
<td width="57"><input type="submit" value="Enviar" /></td>
</tr>
</table>
</form>
</fieldset>
</div>

<h3 style="color:#dcab4c" align="center">&nbsp;</h3>
<h3 style="color:#dcab4c" align="right"><a href="paquetes.php">Ver paquetes</a></h3>
<h3 style="color:#dcab4c" align="center">&nbsp;</h3>
<h3 style="color:#dcab4c" align="center">&nbsp;</h3>
<h3 style="color:#dcab4c" align="center">&nbsp;</h3>
<h3 style="color:#dcab4c" align="center">CATEGORÍAS</h3>
</article>



<!-- aside -->
<!--footer -->
<?php include("footer.php");?>

</section>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>



Y la programación de la segunda página es:

<?php require_once('../Connections/fidprensa.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;
}
}

$colname_Recordset1 = "-1";
if (isset($_POST['Introduce una palabra'])) {
$colname_Recordset1 = $_POST['Introduce una palabra'];
}
mysql_select_db($database_fidprensa, $fidprensa);
$query_Recordset1 = sprintf("SELECT descripcion FROM archivos WHERE descripcion LIKE %s", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"));
$Recordset1 = mysql_query($query_Recordset1, $fidprensa) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fid prensa</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>


<body>

<img src="images/logo.png" width="100%" />




<div id="content">
<div id="contenido">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3 align="center">&nbsp;</h3>
<h3 align="center">&nbsp;</h3>
<h3 align="center">&nbsp;</h3>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<br>


<table border="0" cellpadding="5" cellspacing="5">
<?php do { ?>
<tr>
<td><img src="<?php echo "comercio/imagenes/" . $row_Recordset1['archivo']; ?>" width="160" height="120" /></td>
<td>
<strong><?php echo $row_Recordset1['nombre_imagen']; ?></strong>
<br>
<p><?php echo $row_Recordset1['descripcion']; ?></p>
<p>
<b>Tipo: </b><?php echo $row_Recordset1['tipo_imagen']; ?>
<b> Palabras clave: </b><?php echo $row_Recordset1['palabras_clave']; ?>
</p>
</td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>



</div>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>



Todo lo he hecho con dreamweaver, pero evidentemente tengo un error que no estoy detectando, si alguien puede ayudarme lo agradeceré mucho.