Risultati da 1 a 2 di 2

Discussione: motore di ricerca

  1. #1
    L'avatar di Sargon
    Sargon è offline Utente del Forum
    Data Registrazione
    Mar 2012
    Messaggi
    41

    motore di ricerca

    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

    Codice 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 
    "&nbsp;";
    echo 
    $row['autore']; 
    echo 
    "<p>";
    echo 
    "<b>";
    echo 
    "Year:";
    echo 
    "</b>";
    echo 
    "&nbsp;";
    echo 
    $row['anno']; 
    echo 
    "&nbsp;";
    echo 
    "<b>";
    echo 
    $row['parolechiave'];
    echo 
    "</b>";
    echo 
    "<p>";
    echo 
    "<p>";
    echo 
    "<p>";
    echo 
    "<hr>";





    }





     
     
    ?>

    [QUOTE][/QUOTE]

  2. #2
    L'avatar di Eliox
    Eliox è offline Moderatore
    Data Registrazione
    Feb 2005
    Messaggi
    4,392
    Codice PHP:
    if(mysql_num_rows($this->res)==0)
    {
     echo 
    "Nessun risultato trovato";


Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  •