Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15
  1. #1

    Secondo campo ricerca non funzionante!!

    Ciao, scusate ragazzi ma di php ne capisco poco niente e non riesco a far lavorare il secondo campo della ricerca:
    ?>
    <form method="POST">
    Ricerca : <input type="text" name="term" id="term" />

    Ricerca2: <input type="text" name="term2" id="term2" />

    <input type="submit" name="search" id="search" value="Search" />
    </form>
    <?
    }elseif(isset($_POST['search'])){
    $term = addslashes($_POST['term']);
    $search = mysql_query("SELECT * FROM `immobili` WHERE `Provincia` LIKE '%$term%' AND `Citta` LIKE '%$term2%'" );
    $total = mysql_num_rows($search);
    if($total == 0){
    echo 'Nessun risultato ';
    }else{
    while($r = mysql_fetch_array($search)){ echo $r['Provincia'] ; echo $r['Citta'] ; echo $r['Zona'] ; echo $r['Tipologia'] ; echo $r['Mq'] ; echo $r['N° locali'] ; echo $r['Prezzo'] ; echo $r['Vendita'] ; echo $r['Affitto'] ; echo $r['Descrizione'] . '
    ';
    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>

    Poi vorrei incolonnare decentemente i dati che estrae la query, potete farmi un esempio o dirmi su che istruzioni devo lavorare?
    Grazie.
    qui trovate come lavora adesso: www.panesegreto.lowweb.it

  2. #2
    Utente di HTML.it L'avatar di telegio
    Registrato dal
    Sep 2001
    Messaggi
    2,591
    non so se lo hai tralasciato ma oltre a
    $term = addslashes($_POST['term']);
    hai dimenticato
    $term2 = addslashes($_POST['term2']);


    per inTABELLARE i risultati hai bisogno di una tabella..

  3. #3
    a prima vista mi sembra che non recuperi term2 dal post:

    Codice PHP:
    $term2 addslashes($_POST['term2']); 

  4. #4
    Poi vorrei incolonnare decentemente i dati che estrae la query, potete farmi un esempio o dirmi su che istruzioni devo lavorare?
    Grazie.
    qui trovate come lavora adesso: www.panesegreto.lowweb.it
    bè dipende... puoi utilizzare table old style di html oppure css, jquery, ajax etc...

    guarda questi esempi

  5. #5
    Grazie, ora lavora, piccola dimenticanza
    Però ho un problema con la tabella
    come si può vedere:
    www.panesegreto.lowweb.it

  6. #6
    Utente di HTML.it L'avatar di telegio
    Registrato dal
    Sep 2001
    Messaggi
    2,591
    ..codice completo..

  7. #7
    ?>
    <form method="POST">
    Ricerca : <input type="text" name="term" id="term" />

    Ricerca2: <input type="text" name="term2" id="term2" />

    <input type="submit" name="search" id="search" value="Search" />
    </form>
    <?
    }elseif(isset($_POST['search'])){
    $term = addslashes($_POST['term']);
    $term2 = addslashes($_POST['term2']);
    $search = mysql_query("SELECT * FROM `immobili` WHERE `Provincia` LIKE '%$term%' AND `Citta` LIKE '%$term2%'" );
    $total = mysql_num_rows($search);
    if($total == 0){
    echo 'Nessun risultato ';
    }else{
    while($r = mysql_fetch_array($search)){
    echo $r['Provincia'] ; echo $r['Citta'] ; echo $r['Zona'] ; echo $r['Tipologia'] ; echo $r['Mq'] ; echo $r['N° locali'] ; echo $r['Prezzo'] ; echo $r['Vendita'] ; echo $r['Affitto'] ; echo $r['Descrizione'] . '
    ';
    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>
    </body>
    </html>
    <table width="100%" border="1">
    <caption>
    Risultati ricerca
    </caption>
    <tr>
    <th scope="col">Provincia</th>
    <th scope="col">Città</th>
    <th scope="col">Zona</th>
    <th scope="col">Tipologia</th>
    <th scope="col">Mq</th>
    <th scope="col">N° locali</th>
    <th scope="col">Prezzo</th>
    <th scope="col">Vendita</th>
    <th scope="col">Affitto</th>
    <th scope="col">Descrizione</th>
    <th scope="col"></th>
    </tr>
    <tr>
    <td>$r['Provincia']</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    </table>

  8. #8
    Utente di HTML.it L'avatar di telegio
    Registrato dal
    Sep 2001
    Messaggi
    2,591
    oh madonna...
    la tabella va nel ciclo while e prima del tag di chiusura del body..

    Codice PHP:
    <form method="POST">
    Ricerca : <input type="text" name="term" id="term" />

    Ricerca2: <input type="text" name="term2" id="term2" />

    <input type="submit" name="search" id="search" value="Search" />
    </form>
    <?
    }elseif(isset($_POST['search'])){
    $term addslashes($_POST['term']);
    $term2 addslashes($_POST['term2']);
    $search mysql_query("SELECT * FROM `immobili` WHERE `Provincia` LIKE '%$term%' AND `Citta` LIKE '%$term2%'" );
    $total mysql_num_rows($search);
    if(
    $total == 0){
    echo 
    'Nessun risultato ';
    }else{
    while(
    $r mysql_fetch_array($search)){
    ?>
    <table width="100%" border="1">
    <caption>
    Risultati ricerca
    </caption>
    <tr>
    <th scope="col">Provincia</th>
    <th scope="col">Città</th>
    <th scope="col">Zona</th>
    <th scope="col">Tipologia</th>
    <th scope="col">Mq</th>
    <th scope="col">N° locali</th>
    <th scope="col">Prezzo</th>
    <th scope="col">Vendita</th>
    <th scope="col">Affitto</th>
    <th scope="col">Descrizione</th>
    <th scope="col"> </th>
    </tr>
    <tr>
    <td><?php echo $r['Provincia']; ?></td>
    <td><?php echo $r['Zona']; ?> </td>
    <td>qua ci metti gli altri campi, uno per ogni cella </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    </table>

    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>
    </body>
    </html>

  9. #9
    Scusa telegio.....l'avevo detto che sono all'inizio (....forse anche un pò prima!!!)

  10. #10
    Utente di HTML.it L'avatar di telegio
    Registrato dal
    Sep 2001
    Messaggi
    2,591

    perdonami c'è un errore che ho visto ora

    dove vedi
    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>

    devi mettere
    <?php
    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>

    ovviamente dimmi se funziona..

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.