Amigos acabo de encontrar una pagina que tiene codigo de PHP y ajax, la direccion es:
http://www.baluart.net, el cual tienen un codigo fuente de un buscador con ajax, el cual es bastante sencillo y muy practico, el problema que tengo es el mismo lo hace a una BD mysql que tiene caracteristica desde el punto de vista mio muy especiales que yo nunca en visto y trabajado, yo logre conectar la BD y todo pero cuando deseo buscar algo me sale este error:
Can't find FULLTEXT index matching the column list
Segun lo que puedo entender es que mis campos no estan FULLTEXT o algo asi, el codigo fuente del php que hace esto es ele siguiente:
Código PHP:
<?php require_once('conexion.php');
$link=conectar();
?>
<?php
$maxRows_rsSearchResults = 10;
$pageNum_rsSearchResults = 0;
if (isset($_GET['pageNum_rsSearchResults'])) {
$pageNum_rsSearchResults = $_GET['pageNum_rsSearchResults'];
}
$startRow_rsSearchResults = $pageNum_rsSearchResults * $maxRows_rsSearchResults;
$SearchString_rsSearchResults = "-1";
if (isset($_GET['SearchString'])) {
$SearchString_rsSearchResults = (get_magic_quotes_gpc()) ? $_GET['SearchString'] : addslashes($_GET['SearchString']);
}
mysql_select_db($database_connBlog, $link);
$query_rsSearchResults = sprintf("SELECT * FROM datos_personales1 WHERE MATCH (ci, nombre, apellido) AGAINST ('%%%s%%') ORDER BY ci DESC", $SearchString_rsSearchResults);
$query_limit_rsSearchResults = sprintf("%s LIMIT %d, %d", $query_rsSearchResults, $startRow_rsSearchResults, $maxRows_rsSearchResults);
$rsSearchResults = mysql_query($query_limit_rsSearchResults, $link) or die(mysql_error());
$row_rsSearchResults = mysql_fetch_assoc($rsSearchResults);
if (isset($_GET['totalRows_rsSearchResults'])) {
$totalRows_rsSearchResults = $_GET['totalRows_rsSearchResults'];
} else {
$all_rsSearchResults = mysql_query($query_rsSearchResults);
$totalRows_rsSearchResults = mysql_num_rows($all_rsSearchResults);
}
$totalPages_rsSearchResults = ceil($totalRows_rsSearchResults/$maxRows_rsSearchResults)-1;
$queryString_rsSearchResults = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsSearchResults") == false &&
stristr($param, "totalRows_rsSearchResults") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsSearchResults = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsSearchResults = sprintf("&totalRows_rsSearchResults=%d%s", $totalRows_rsSearchResults, $queryString_rsSearchResults);
?>
<!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=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body>
<div id="contenido">
<?php if ($totalRows_rsSearchResults > 0) { // Show if recordset not empty ?>
<?php do { ?>
<li><a href="http://www.tudominio.net/articulo.php?id=<?php echo $row_rsSearchResults['id_art'];?>"><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['title_art']);?></a></li>
<?php } while ($row_rsSearchResults = mysql_fetch_assoc($rsSearchResults));?>
<?php } // Show if recordset not empty ?>
</div>
</body>
</html>
<?php
mysql_free_result($rsSearchResults);
?>
el formulario de busqueda es el siguiente:
Código PHP:
<!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=iso-8859-1" />
<title>BaluArt.net - Crear un LiveSearch con Ajax, PHP y MySQL</title>
<script type="text/javascript" src="livesearch.js"></script>
<style type="text/css">
body{background-color:#CAEAFF;}
.LSresult{
background-color:#fff;
width: 400px;
margin:0;
padding:0;
}
h1{
font-family:Georgia, "Times New Roman", Times, serif;
font-size:20px;}
p {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;}
</style>
</head>
<body onload="liveSearchInit()" >
<div><h1>LIVESEARCH</h1></div>
<form onsubmit="return liveSearchSubmit()" name="searchform" method="get" action="./" id="searchform">
<input type="text" id="livesearch" name="q" size="15" onkeypress="liveSearchStart()" />
<div class="LSresult" id="LSResult">
<ul id="LSShadow"> </ul></div>
</form>
<div><p>Intenta con las siguientes palabras: Bienvenidos, Vintage, extensiones, recursos, u otras.</p>
<p>Aprende como crearlo con <a href="http://www.baluart.net/articulo.php?id_art=78">este tutorial</a></p>
</div>
</body>
</html>
y el JS, es:
continua....