Visualizzazione dei risultati da 1 a 9 su 9

Discussione: filtri collonne

  1. #1

    filtri collonne

    filtri collonne

    id Nome Cognome Email
    0 mario rossi abc@abc.it
    1 gigi bianchi abc@def.it
    2 andrea neri abc@ghi.it

    questo codice crea la tabella sopra

    <html>
    <link rel="stylesheet" type="text/css" href="stile.css">
    <head>
    <?php
    // Comessione database
    mysql_connect("localhost", "root", "marcoprove") or die ("Connessione non riuscita: " . mysql_error());
    mysql_select_db("utenti") or die ("Connessione non riuscita: " . mysql_error());

    // estrazione dati
    $result = mysql_query("SELECT * FROM anagrafica")
    or die ("query non eseguita: " . mysql_error());

    echo"<table>";
    echo "<tr> <th>id</th> <th>Nome</th> <th>Cognome</th> <th>Email</th> </tr>";
    // array che raccoglie i risultati
    while($row = mysql_fetch_array( $result )) {
    // stampa tabella
    echo "<tr><th>";
    echo $row['id'];
    echo "</td><td>";
    echo $row['Nome'];
    echo "</td><td>";
    echo $row['Cognome'];
    echo "</td><td>";
    echo $row['Email'];

    }

    ?>
    </body>
    </html>

    Sul intestazione della colonna nome vorrei creare un filtro esempio
    se seleziono mario mi da i reccord solo di Mario come posso fare???

  2. #2
    Utente di HTML.it L'avatar di Fractals87
    Registrato dal
    Apr 2008
    Messaggi
    1,202
    non è proprio cosi immediato... ci sono due strade filtro lato client e filtro lato server

    o metti a fianco di ogni intestazione un campo text che all'evento onblur ricarica la pagina con il contenuto della text e concateni alla tua select il where

    oppure lato client ti scarichi j query qualche plug-in per le tabelle e il gioco è fatto

    esempio

    http://www.tripwiremagazine.com/2009...ml-tables.html
    Che mestiere difficile.....essere da soli ancora di più

  3. #3
    <html>
    <link rel="stylesheet" type="text/css" href="stile.css">
    <head>
    <?php
    // Comessione database
    mysql_connect("localhost", "root", "marcoprove") or die ("Connessione non riuscita: " . mysql_error());
    mysql_select_db("utenti") or die ("Connessione non riuscita: " . mysql_error());

    // estrazione dati
    if(isset($_GET["nome"])){
    $name = $_GET["nome"];
    }else{
    $result = mysql_query("SELECT * FROM anagrafica")
    or die ("query non eseguita: " . mysql_error());
    }
    $result = mysql_query("SELECT * FROM anagrafica WHERE nome='$nome'")
    or die ("query non eseguita: " . mysql_error());
    echo"<table>";
    echo "<tr> <th>id</th> <th>Nome</th> <th>Cognome</th> <th>Email</th> </tr>";
    // array che raccoglie i risultati
    while($row = mysql_fetch_array( $result )) {
    // stampa tabella
    echo "<tr><th>";
    echo $row['id'];
    echo "</td><td>";
    echo ''.$row['Nome']."";
    echo "</td><td>";
    echo $row['Cognome'];
    echo "</td><td>";
    echo $row['Email'];

    }

    ?>
    </body>
    </html>

    Vorrei far vedere un filtro sul campo nome che mi visualizzi solo il nome selezionato

  4. #4
    Utente di HTML.it L'avatar di Fractals87
    Registrato dal
    Apr 2008
    Messaggi
    1,202
    $sql="SELECT * FROM anagrafica ";

    if(isset($_GET["nome"])){
    $sql.=" WHERE nome='".$_GET['nome']."'";
    }
    while($result = mysql_query($sql)){
    echo "miei dati";
    }

    perdona sicuramente i milio di errori in due righe di codice ma la logica è questa piu o meno
    Che mestiere difficile.....essere da soli ancora di più

  5. #5
    scusa ma dove lo devo inserire quel pezzo dicodice così?


    <html>
    <link rel="stylesheet" type="text/css" href="stile.css">
    <head>
    <?php
    // Comessione database
    mysql_connect("localhost", "root", "marcoprove") or die ("Connessione non riuscita: " . mysql_error());
    mysql_select_db("utenti") or die ("Connessione non riuscita: " . mysql_error());

    // estrazione dati
    $sql="SELECT * FROM anagrafica ";

    if(isset($_GET["nome"])){
    $sql.=" WHERE nome='".$_GET['nome']."'";
    }
    while($result = mysql_query($sql)){
    echo "miei dati";
    }
    echo"<table>";
    echo "<tr> <th>id</th> <th>Nome</th> <th>Cognome</th> <th>Email</th> </tr>";
    // array che raccoglie i risultati
    while($row = mysql_fetch_array( $result )) {
    // stampa tabella
    echo "<tr><th>";
    echo $row['id'];
    echo "</td><td>";
    echo ''.$row['Nome']."";
    echo "</td><td>";
    echo $row['Cognome'];
    echo "</td><td>";
    echo $row['Email'];

    }

    ?>
    </body>
    </html>

  6. #6
    html>
    <link rel="stylesheet" type="text/css" href="stile.css">
    <head>
    <?php
    // Comessione database
    mysql_connect("localhost", "root", "marcoprove") or die ("Connessione non riuscita: " . mysql_error());
    mysql_select_db("utenti") or die ("Connessione non riuscita: " . mysql_error());

    // estrazione dati

    $result = mysql_query("SELECT * FROM anagrafica")
    or die ("query non eseguita: " . mysql_error());

    if(isset($_GET["nome"])){
    $sql.=" WHERE nome='".$_GET['nome']."'";
    }
    while($result = mysql_query($sql)){
    echo "miei dati";
    }

    echo"<table>";
    echo "<tr> <th>id</th> <th>Nome</th> <th>Cognome</th> <th>Email</th> </tr>";
    // array che raccoglie i risultati
    while($row = mysql_fetch_array( $result )) {
    // stampa tabella
    echo "<tr><th>";
    echo $row['id'];
    echo "</td><td>";
    echo $row['Nome'];
    echo "</td><td>";
    echo $row['Cognome'];
    echo "</td><td>";
    echo $row['Email'];

    }

    ?>
    </body>
    </html>
    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in linea 24

  7. #7
    Utente di HTML.it L'avatar di Fractals87
    Registrato dal
    Apr 2008
    Messaggi
    1,202
    <html>
    <link rel="stylesheet" type="text/css" href="stile.css">
    <head>
    <?php
    // Comessione database
    mysql_connect("localhost", "root", "marcoprove") or die ("Connessione non riuscita: " . mysql_error());
    mysql_select_db("utenti") or die ("Connessione non riuscita: " . mysql_error());

    // estrazione dati

    $sql="SELECT * FROM anagrafica";

    if(isset($_GET["nome"])){
    $sql.=" WHERE nome='".$_GET['nome']."'";
    }

    $result = mysql_query($sql);

    echo"<table>";
    echo "<tr> <th>id</th> <th>Nome</th> <th>Cognome</th> <th>Email</th> </tr>";

    while($row = mysql_fetch_array( $result )) {
    // stampa tabella
    echo "<tr>";
    echo "<td>".$row['id']."<td>";
    echo "<td>".$row['Nome']."<td>";
    echo "<td>".$row['Cognome']."<td>";
    echo "<td>".$row['Email']."<td>";
    echo "</tr>";
    }

    echo"</table>";

    ?>
    </body>
    </html>
    Che mestiere difficile.....essere da soli ancora di più

  8. #8
    echo "<td>".$row['Nome']."</td>";
    come faccio a fare in modo che sia linkabile???

  9. #9
    Codice PHP:
    echo "<td><a href=\"link della pagina\">$row[Nome]</a></td>"
    CODENCODE \ Branding \ Design \ Marketing
    www.codencode.it

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.