Ciao a tutti, ho un problema con il mio motore di ricerca full text,
vorrei inserire un messaggio di errore sotto gli echo..... tipo.... non è stato trovato il campo che cerchi.... oppure compila il campo.....
mi potete dare una mano?
grazziiieeeee mille
vorrei inserire un messaggio di errore sotto gli echo..... tipo.... non è stato trovato il campo che cerchi.... oppure compila il campo.....
mi potete dare una mano?
grazziiieeeee mille
PHP:
<body>
<div id="Layer3">
<form action='free_search.php' method='post'>
<p class="Stile1">Free Search (All fields).</p>
<p class="Stile2">The keyword must have 4 characters or more. </p>
<p><br />
<input name='key' type='text' size="100" />
<br />
</p>
<p>
<input name="submit" type='submit' value='Search' />
</p>
</form>
<p><font face="Arial" size="2">
<?php
$key = $_POST['key'];
class Search
{
#CONFIGURA
#Parametri ricerca
var $fulltext = "autore,anno,parolechiave,autorescheda";
var $table = "bibliografia";
#parametri db
var $host = "";
var $password = "";
var $user = "";
var $db = "";
#
var $pf = "f";
#
#
var $key;
var $conn;
var $res;
var $total;
function Search($key)
{
$this->key = $key;
}
function DbConnectAndSelect()
{
$this->conn = @mysql_connect($this->host, $this->user, $this->password) or die ("Impossibile stabilire una connessione con il
server.<br>MySql risponde: " . mysql_error() . "<br>Il codice errore é:" . mysql_errno());
@mysql_select_db($this->db, $this->conn) or die ("Impossibile connettersi al database $this->db.<br>MySql risponde: " . mysql_error() .
"<br>Il codice errore é:" . mysql_errno());
//
mysql_set_charset('utf8'); //
}
function GetResource()
{
$this->DbConnectAndSelect();
$sql = "SELECT *, MATCH($this->fulltext) AGAINST('$this->key' IN BOOLEAN MODE) AS tot FROM $this->table WHERE MATCH($this->fulltext)
AGAINST('$this->key' IN BOOLEAN MODE) ORDER BY tot DESC";
$this->res = mysql_query($sql, $this->conn);
}
function CalcScore($tot)
{
switch($this->pf)
{
case "f":
$key_array = explode(" ", $this->key);
$this->total = count($key_array);
return $tot . " / " . $this->total;
break;
case "p":
$key_array = explode(" ", $this->key);
$this->total = count($key_array);
$output = intval($tot / $this->total * 100) . "%";
return $output;
break;
default:
$key_array = explode(" ", $this->key);
$this->total = count($key_array);
return $tot . " / " . $this->total;
}
}
}
$search = new Search($key);
$search->GetResource();
$autore=$row['autore'];
$parolechiave=$row['parolechiave'];
$autorescheda=$row['autorescheda'];
while ($row = mysql_fetch_array($search->res))
{
echo "<b>";
echo "Author/s:";
echo "</b>";
echo " ";
echo $row['autore'];
echo "<p>";
echo "<b>";
echo "Year:";
echo "</b>";
echo " ";
echo $row['anno'];
echo " ";
echo "<b>";
echo $row['parolechiave'];
echo "</b>";
echo "<p>";
echo "<p>";
echo "<p>";
echo "<hr>";
}
?>
[QUOTE][/QUOTE]