Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Creazione tabella dinamica per Rubrica

    Salve a tutti ragazzi,
    come al solito chiedo aiuto a voi
    devo creare una tabella dinamica nella quale inserire i record che estraggo dal database secondo un determinato criterio di ricerca.

    Questo è il codice PHP che ho creato:

    Codice PHP:
    if (isset($_POST['send'])) {
                
    $funz trim(stripslashes($_POST['funz']));
                
                if (
    $funz == "") {
                    echo 
    "<script type=\"text/javascript\">alert(\"Non hai selezionato alcun campo per la ricerca!\\nVerifica e riprova!!\"); history.go(-1)</script>";
                    exit;
                }
                
                
    $check2 mysql_query("SELECT * FROM $tbl_name WHERE funzione = '$funz'");
                
    $arr2 mysql_fetch_row($check2);
                
                
    $count="1";
                 
    $tab=""
                 
    $tab.="<table width=\"983\" border=\"1\"> 
                                <thead> 
                                <tr> 
                                <td width=\"31\" align=\"center\">[b]ID[/b]</td> 
                                <th width=\"100\" align=\"center\">[b]NOME[/b]</th> 
                                <th width=\"100\" align=\"center\">[b]COGNOME[/b]</th> 
                                <th width=\"150\" align=\"center\">[b]E-MAIL[/b]</th> 
                                <th width=\"88\" align=\"center\">[b]FAX[/b]</th> 
                                <th width=\"88\" align=\"center\">[b]FUNZIONE[/b]</th> 
                                <th width=\"88\" align=\"center\">[b]ISTITUTO[/b]</th> 
                                <th width=\"90\" align=\"center\">[b]SEDE[/b]</th> 
                                </tr> 
                                </thead>"

                
                while (
    $arr2[0]!="") {
                    echo 
    $count;
                    
                    
    $tab.=
                           <tbody align="
    ."center"."> 
                           <tr> 
                           <td>"
    .$count."</td> 
                           <td>"
    .correzione($arr2[5])."</td> 
                           <td>"
    .correzione($arr2[6])."</td> 
                           <td>"
    .$arr2[7]."</td> 
                           <td>"
    .$arr2[8]."</td> 
                           <td>"
    .$arr2[11]."</td> 
                           <td>"
    .$arr2[9]."</td> 
                           <td>"
    .$arr2[10]."</td>
                           <td>"
    .$arr2[18]."</td> 
                        </tr> 
                        </tbody>"

                        
                    
    $check2 mysql_query("SELECT * FROM $tbl_name WHERE funzione = '".$funz."'");
                    
    $arr2 mysql_fetch_row($check);
                
                      
    $count++;
                    
                }
                
    $tab.="</table>";
                echo 
    $tab;
        } 
    il problema è che il while mi si blocca sempre subito e mi scrive un solo risultato nella tabella, senza mettere gli altri....
    a cosa può essere dovuto?
    grazie

  2. #2
    rettifico allora....
    avevo commesso un errore di scrittura nel secondo $arr2 = mysql_fetch_row($check);
    era check2 e non check....

    il problema è che adesso sta lì a caricare e il while non finisce mai...praticamente va in loop infinito

  3. #3
    RAGAZZI HO RISOLTO....
    ho usato mysql_fetch_assoc e adesso va.
    grazie cmq

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.