Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente bannato
    Registrato dal
    Jan 2002
    Messaggi
    413

    [PHP] Ciclare per visualizzare

    Ciao

    ho un DB che contiene dei dati. Vorrei fare un ciclo per mostrarli tutti. Come si fa?
    Ecco il codice che uso:


    $hostname_strat = "localhost";
    $database_strat = "strategie";
    $username_strat = "strategie";
    $password_strat = "strategie";
    $strat = mysql_pconnect($hostname_strat, $username_strat, $password_strat) or die(mysql_error());


    mysql_select_db($database_strat,$strat);
    $sql = mysql_query("SELECT " .$lingua ." FROM servizi");

    $rowstat = mysql_fetch_array($sql1);


    Mi connetto al DB, poi faccio una query alla mia tabella. Come faccio a mostrare tutti i dati in quella tabella con un ciclo?
    Grazie

  2. #2
    Utente di HTML.it L'avatar di pgm
    Registrato dal
    Apr 2002
    Messaggi
    1,281
    ciao

    per creare un tabella da più record estratti puoi fare cosi:
    Codice PHP:

    $hostname_strat 
    "localhost"
    $database_strat "strategie"
    $username_strat "strategie"
    $password_strat "strategie"
    $strat mysql_connect($hostname_strat$username_strat$password_strat) or die(mysql_error()); 


    mysql_select_db($database_strat);

    $sql mysql_query("SELECT " .$lingua ." FROM servizi"); 

    $str "";

    $str .= "<table>";
    while(
    $rowstat mysql_fetch_array($sql);){
       
    $str .= "<tr>";
       
    $str .= "<td>{$row['campo1']}</td>";
       
    $str .= "<td>{$row['campo2']}</td>";
       
    $str .= "</tr>";
    }
    $str .= "</table>";

    echo 
    $str
    richiamando il mysql_fetch_array tramite il ciclo while, vengono create tante "righe" quanti sono record nel db


  3. #3
    Utente bannato
    Registrato dal
    Jan 2002
    Messaggi
    413
    grazie


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.