RISOLTO Tabella in PHP valori MySQL

Stato
Discussione chiusa ad ulteriori risposte.

FrancescoZoino0

Nuovo Utente
10
2
Ciao a tutti, sto sviluppando uno script per mostrare all'interno di una tabella tutti i valori (filtrati) dalla tabella del database MySQL.
Il problema rilevante, non è nel mostrare i risultati, poiché essi vengono correttamente visualizzati.
Il problema risulta essere nella formattazione degli stessi, in quanto il primo risultato viene visualizzato correttamente (allego screenshot), mentre tutti gli altri non seguono la formattazione indicata, dove sbaglio?
Vi sarei grato dell'aiuto.
l12.PNG
Capisco che la visualizzazione non è di alta qualità a causa delle censure delle informazioni, pertanto potrebbero esserci difficoltà ad individuare i campi corretti.

Di seguito il codice:
PHP:
     <div class="container-fluid py-4">
      <div class="row">
        <div class="col-12">
          <div class="card mb-4">
            <div class="card-header pb-0">
              <h6>Contatti inseriti</h6>
            </div>
            <div class="card-body px-0 pt-0 pb-2">
              <div class="table-responsive p-0">
 <?php
$partnerid = $_SESSION['username'];
$link = mysqli_connect("localhost", "user", "paswd", "nomedb");

if($link === false){
    die("ERRORE: Impossibile eseguire la connessione al database. " . mysqli_connect_error());
}
 
$sql = "SELECT * FROM contatti WHERE partner='$partnerid'";
if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){
        echo "<table class='table align-items-center mb-0'>";
          echo "<thead>";
            echo "<tr>";
                echo "<th class='text-uppercase text-secondary text-xxs font-weight-bolder opacity-7'>Id Contatto</th>";
                echo "<th class='text-uppercase text-secondary text-xxs font-weight-bolder opacity-7'>Nominativo</th>";
                echo "<th class='text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7'>Recapito telefonico</th>";
                echo "<th class='text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7'>Data di inserimento</th>";
                echo "<th class='text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7'>Stato</th>";
            echo "</tr>";
            echo "</thead>";
        while($row = mysqli_fetch_array($result)){
            echo "<tr>";
            echo "<td class='align-middle text-center'>";
               echo "<span class='text-secondary text-xs font-weight-bold'>" . $row['id'] . "</span>";
            echo "</td>";
            echo "<td>";
            echo "<div class='d-flex px-2 py-1'>";
            echo "<div class='d-flex flex-column justify-content-center'>";
                echo "<h6 class='mb-0 text-sm'>" . $row['nome'] . "&nbsp;" . $row['cognome'] . "</h6>";
                echo "<p class='text-xs text-secondary mb-0'>" . $row['indirizzo_email'] . "</p>";
            echo "</div>";
            echo "</div>";
            echo "</td>";
            echo "<td>";
            echo "<p class='text-xs font-weight-bold mb-0'>" . $row['recapito_telefonico'] . "</p>";
            echo "</td>";
            echo "<td class='align-middle text-center'>";
              echo "<span class='text-secondary text-xs font-weight-bold'>" . $row['data_inserimento'] . "</span>";
            echo "</td>";
            echo "<td>";
              echo "<span class='badge badge-sm bg-gradient-success'>" . $row['stato'] . "</span>";
            echo "</td>";   
            echo "</tr>";
            echo "</tbody>";
            echo "</table>";
        }
        echo "</table>";
  
        mysqli_free_result($result);
    } else{
        echo "Nessun contatto trovato.";
    }
} else{
    echo "ERRORE: Impossibile eseguire la funzione $sql. " . mysqli_error($link);
}
 
mysqli_close($link);
?>
              </div>
            </div>
          </div>
        </div>
      </div>
 

Moffetta88

Moderatore
Staff Forum
Utente Èlite
20,558
12,947
CPU
i5-4690
Dissipatore
DEEPCOOL CAPTAIN 240EX
Scheda Madre
MSI Z97 U3 PLUS
HDD
KINGSTON SSD KC400 240GB
RAM
24GB BALLISTIX SPORT @2133MHz
GPU
STRIX GTX980 DC2OC
Audio
INTEGRATA
Monitor
AOC G2590VXQ
PSU
BEQUIET! System Power 7 500W
Case
DEEPCOOL MATREXX 55
Periferiche
NESSUNA
Net
EOLO 100
OS
UBUNTU/WINDOWS11
Ti sei perso questi dentro al ciclo while
PHP:
echo "</tbody>";
echo "</table>";
 

Moffetta88

Moderatore
Staff Forum
Utente Èlite
20,558
12,947
CPU
i5-4690
Dissipatore
DEEPCOOL CAPTAIN 240EX
Scheda Madre
MSI Z97 U3 PLUS
HDD
KINGSTON SSD KC400 240GB
RAM
24GB BALLISTIX SPORT @2133MHz
GPU
STRIX GTX980 DC2OC
Audio
INTEGRATA
Monitor
AOC G2590VXQ
PSU
BEQUIET! System Power 7 500W
Case
DEEPCOOL MATREXX 55
Periferiche
NESSUNA
Net
EOLO 100
OS
UBUNTU/WINDOWS11
Se il problema è risolto, cambia il tag del titolo da [PROBLEMA] a [RISOLTO]
 
Stato
Discussione chiusa ad ulteriori risposte.

Entra

oppure Accedi utilizzando
Discord Ufficiale Entra ora!

Discussioni Simili