<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Motore di ricerca con MATCH e AGAINST]]></title><description><![CDATA[<p dir="auto">Salve a tutti,<br />
una cosa molto semplice: siccome ancora non ho dimestichezza con la versione 5 di PHP, avevo scaricato uno script per un motore di ricerca interno, solo che non riesco a far passare la variabili POST in key. Qualcuno mi può gentilmente aiutare?</p>
<p dir="auto">pagina 1:</p>
<pre><code class="language-html">&lt;form name='ricerca' method='post' action='ricerca.php'&gt;
&lt;input name="key" type="text" id="mostraricerca" placeholder="Parola chiave..." size="20" maxlength="20" &gt;&lt;input type="submit" name="ricerca" value="Cerca"&gt;&lt;/form&gt;
</code></pre>
<p dir="auto">pagina 2:</p>
<pre><code class="language-php">$key=$_POST['mostraricerca'];

    class Search
    {
        #CONFIGURA
        #Parametri ricerca
        var $fulltext = "titolo";
        var $table = "database";
        #parametri db
        var $host = "localhost";
        var $password = "";
        var $user = "root";
        var $db = "database";
        #metodo score -&gt; p in percentuale, f in frazione
        var $pf = "f";
        #FINE CONFIGURAZIONE
        
        #NON EDITARE OLTRE QUESTA LINEA
        var $key;
        var $conn;
        var $res;
        var $total;
     
            function Search($key)
            {
                $this-&gt;key = $key;
            }
     
            function DbConnectAndSelect()
            {
                $this-&gt;conn = @mysql_connect($this-&gt;host, $this-&gt;user, $this-&gt;password) or die ("Impossibile stabilire una connessione con il server.&lt;br&gt;MySql risponde: " . mysql_error() . "&lt;br&gt;Il codice errore é:" . mysql_errno());
     
                @mysql_select_db($this-&gt;db, $this-&gt;conn) or die ("Impossibile connettersi al database $this-&gt;db.&lt;br&gt;MySql risponde: " . mysql_error() . "&lt;br&gt;Il codice errore é:" . mysql_errno());
            }
     
            function GetResource()
            {
                $this-&gt;DbConnectAndSelect();
                $sql = "SELECT *, MATCH($this-&gt;fulltext) AGAINST('$this-&gt;key' IN BOOLEAN MODE) AS tot FROM $this-&gt;table WHERE MATCH($this-&gt;fulltext) AGAINST('$this-&gt;key' IN BOOLEAN MODE) ORDER BY tot DESC";
                $this-&gt;res = mysql_query($sql, $this-&gt;conn);
     
            }
     
            function CalcScore($tot)
            {
                switch($this-&gt;pf)
                {
                    case "f":
                    $key_array = explode(" ", $this-&gt;key);
                    $this-&gt;total = count($key_array);
                    return $tot . " / " . $this-&gt;total;
                    break;
                    case "p":
                    $key_array = explode(" ", $this-&gt;key);
                    $this-&gt;total = count($key_array);
                    $output = intval($tot / $this-&gt;total * 100) . "%";
                    return $output;
                    break;
                    default:
                    $key_array = explode(" ", $this-&gt;key);
                    $this-&gt;total = count($key_array);
                    return $tot . " / " . $this-&gt;total;
     
                }
            }
     
    }

    $search = new Search($key);
    $search-&gt;GetResource();
    while ($row = mysql_fetch_array($search-&gt;res))
    {
        echo $row['titolo'] . " score: " . $search-&gt;CalcScore($row['tot']);
    }
</code></pre>
]]></description><link>https://dev.connect.gt/topic/208603/motore-di-ricerca-con-match-e-against</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 23:07:29 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/208603.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Nov 2014 14:34:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Motore di ricerca con MATCH e AGAINST on Sun, 14 Dec 2014 18:51:33 GMT]]></title><description><![CDATA[<p dir="auto">Ci sono diversi errori nella classe e il suo approccio non è del tutto corretto.<br />
Fai una bella cosa:<br />
prendi la porzione di codice che fa la richiesta sql e provala. Se funziona, la classe è errata ( ci sono almeno 2 errori ).</p>
]]></description><link>https://dev.connect.gt/post/1180862</link><guid isPermaLink="true">https://dev.connect.gt/post/1180862</guid><dc:creator><![CDATA[ultima]]></dc:creator><pubDate>Sun, 14 Dec 2014 18:51:33 GMT</pubDate></item></channel></rss>