• User Newbie

    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:
    [php]?>
    <form method="POST">
    Ricerca : <input type="text" name="term" id="term" /><br/>
    Ricerca2: <input type="text" name="term2" id="term2" /><br/>
    <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'] . '<br />';
    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>[/php]

    Poi vorrei incolonnare decentemente i dati che estrae la query, potete farmi un esempio o dirmi su che istruzioni devo lavorare?
    Grazie.


  • User Newbie

    Mancava questo:
    $term2 = addslashes($_POST['term2']);
    .....però rimane il problema del layout dei dati!!!!
    Come faccio?


  • User Attivo

    Ciao,

    potresti utilizzare una tabella.


  • User Newbie

    Grazie, ma non sono in grado di gestire tabelle in PHP!!!! :arrabbiato:


  • User Attivo

    Prova così:
    [php]?>
    <form method="POST">
    Ricerca : <input type="text" name="term" id="term" /><br/>
    Ricerca2: <input type="text" name="term2" id="term2" /><br/>
    <input type="submit" name="search" id="search" value="Search" />
    </form>
    <table>
    <?
    }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 '<tr><td>Nessun risultato</td></tr>';
    }else{
    while($r = mysql_fetch_array($search)){ echo "<tr><td>$r['Provincia']</td><td>$r['Citta']</td><td>$r['Zona']</td><td>$r['Tipologia']</td><td>$r['Mq']</td><td>$r['N° locali']</td><td>$r['Prezzo']</td><td>$r['Vendita']</td><td>$r['Affitto']</td><td>$r['Descrizione']</td></tr>";
    } // End While.
    } // End Else.
    } // End ElseIf.
    ?>
    </table>[/php]

    Ciao,
    Luca Bartoli


  • User Newbie

    Grazie Luca, ho fatto così:
    [php]?>
    <form method="POST">
    Provincia : <input type="text" name="term" id="term" /><br/>
    Comune : <input type="text" name="term2" id="term2" /><br/>
    Zona : <input type="text" name="term3" id="term3" /><br/>
    Tipologia : <input type="text" name="term4" id="term4" /><br/>
    <input type="submit" name="search" id="search" value="Search" />
    </form>
    <?
    }elseif(isset($_POST['search'])){
    $term = addslashes($_POST['term']);
    $term2 = addslashes($_POST['term2']);
    $term3 = addslashes($_POST['term3']);
    $term4 = addslashes($_POST['term4']);
    $search = mysql_query("SELECT * FROM immobili WHERE Provincia LIKE '%$term%' AND Comune LIKE '%$term2%' AND Zona LIKE '%$term3%' AND Tipologia LIKE '%$term4%'" );
    $total = mysql_num_rows($search);
    if($total == 0){
    echo 'Nessun risultato ';
    }else{
    ?>
    <caption>
    <strong>Risultati ricerca</strong>
    </caption>
    <p> </p>
    <tr>
    <table width="100%" border="1">
    <th scope="col">Provincia</th>
    <th scope="col">Comune</th>
    <th scope="col">Zona</th>
    <th scope="col">Tipologia</th>
    <th scope="col">Mq</th>
    <th scope="col">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">Foto</th>
    </tr>
    <?php
    while($r = mysql_fetch_array($search)){
    ?>
    <tr>
    <td><?php echo $r['Provincia']; ?></td>
    <td><?php echo $r['Comune']; ?> </td>
    <td><?php echo $r['Zona']; ?> </td>
    <td><?php echo $r['Tipologia']; ?> </td>
    <td><?php echo $r['Mq']; ?> </td>
    <td><?php echo $r['Locali']; ?> </td>
    <td><?php echo $r['Prezzo']; ?> </td>
    <td><?php echo $r['Vendita']; ?> </td>
    <td><?php echo $r['Affitto']; ?> </td>
    <td><?php echo $r['Descrizione']; ?> </td>
    <td><a href="#" onClick="javascript:window.open('virtual_img/virtual_tour_demo.html','_blank','status=yes,top=0,left=0,width=811,height=561');"><img src="<?php echo $r['Foto']; ?>" /></a></td>
    <tr>
    <?php
    } // End While.
    ?>
    </table>
    <?php
    } // End Else.
    } // End ElseIf.
    ?>
    </body>
    </html>
    [/php]

    Si possono fermare le intestazioni delle colonne ? Così da sapere sempre quali campi sto leggendo !
    Queste:
    <th scope="col">Provincia</th>
    <th scope="col">Comune</th>
    <th scope="col">Zona</th>
    <th scope="col">Tipologia</th>
    <th scope="col">Mq</th>
    <th scope="col">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">Foto</th>

    Grazie, ciao!


  • User Attivo

    In che senso fermare le colonne?


  • User Newbie

    Intendevo fermare "l'intestazione" delle colonne, il titolo della colonna, la prima riga! In modo che quando scorrono le righe di dati la prima riga sia fissa e si possa sempre sapere che dato si sta leggendo !
    Grazie