Salve a tutti
sto scrivendo un paio di pagine in php per gestire una biblioteca
ho dei problemi per la ricerca....
sono riuscito a fare una bella funzione per la ricerca avanzata (controllo in sequenza di tutti in campi in AND e poi via via in OR)
ma non capisco quale possa essere un buon modo per una ricerca "semplice".... cioè..... come estrapolare i risultati da un'unica stringa di ricerca
considerando che potrebbero venire cercate parole appartenenti a più campi ho usato explode, ma non funziona nulla, mi sapete aiutare?
Codice PHP:
if ($_POST['QSearch']!=""){ echo ("<fieldset><legend>Ricerca libera</legend>"); $stringhe=explode(" ", $_POST['Search']); foreach( $stringhe as $stringhecercate) { echo $stringhecercate; $Res= mysql_query("SELECT * FROM Testi WHERE (LOWER(Testi.Posizione) LIKE '%".$stringhecercate."%' OR (LOWER(Testi.Autore) LIKE '%".$stringhecercate."%' OR (LOWER(Testi.Titolo) LIKE '%".$stringhecercate."%' OR (LOWER(Testi.Editore) LIKE '%".$stringhecercate."%' OR (LOWER(Testi.Anno) LIKE '%".$stringhecercate."%' OR (LOWER(Testi.ISBN) LIKE '%".$stringhecercate."%' ORDER BY Testi.Autore;", $MyConn);} if (mysql_num_rows($Res) == 0) echo ("Non è stato trovato niente"); else { echo ("<table class=\"db\">"); while ($Entry= mysql_fetch_array($Res)) echo ("<tr><td>".$Entry['ID']."</td><td>".$Entry['Posizione']."</td><td>".$Entry['Autore']."</td><td>".$Entry['Titolo']."</td><td>".$Entry['Editore']."</td><td>".$Entry['Anno']."</td><td>".$Entry['ISBN']."</td><td>".$Entry['Note']."</td><td>".$Entry['Prestato']."</td></tr>"); echo ("</table>"); } echo ("</fieldset>"); }
l'errore che mi restituisce è
Codice PHP:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/mhd-01/www.nethanel.it/htdocs/biblioteca/cerca.php on line 62
la riga 62 è
Codice PHP:
if (mysql_num_rows($Res) == 0)
grazie!