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

    errore visualizzazione tabella in php [RISOLTO]

    Ho uno stupido problema che non so come risolvere.. ho un file php all'interno del quale richiamo una funzione in questo modo:

    codice:
    <?php
    
    include("../include/select.php");
    
    ?>
    
    <table border="1" width="100%" rules="all">
    <tr>
    <th>OraEvento</th>
    <th>Luogo</th>
    <th>Km</th>
    <th>Evento</th>
    <th>ADBlue</th>
    <th>Note</th>
    <th>SR</th>
    </tr>
    
    <?php
    echo select_movimenti();
    ?>
    
    </table>
    per stampare una tabella contenente dei dati presi da un db, solo che anziché stampare il contenuto dell'array mi stampa il nome dell'array..

    codice:
    function select_movimenti()
    {
    
    $date = select_date();
    $data = $date['giorno'];
    
    $sql=mysql_query('SELECT movimenti.id, movimenti.ora, movimenti.luogo, movimenti.km, movimenti.evento, movimenti.adblue, movimenti.note, semirimorchio.targa from movimenti, semirimorchio where movimenti.id_sr=semirimorchio.id order by id desc') or die(mysql_error());
    
    $html= '';
    
    while($row=mysql_fetch_array($sql))
    {
     $html .= '<tr>';
     $html .= '<td>$row["ora"]</td>';
     $html .= '<td>$row["luogo"]</td>';
     $html .= '<td>$row["km"]</td>';
     $html .= '<td>$row["evento"]</td>';
     $html .= '<td>$row["adblue"]</td>';
     $html .= '<td>$row["targa"]</td>';
     $html .= '<td>$row["note"]</td>';
     $html .= '</tr>';
    }
    return $html;
    }
    come risolvo questo inghippo?..

  2. #2
    questioni di apici. con apice singola non viene risolto il nome della variabile/array.

    codice:
    while($row=mysql_fetch_array($sql))
    {
     $html .= '<tr>';
     $html .= "<td>$row[ora]</td>";
     $html .= "<td>$row[luogo]</td>";
     $html .= "<td>$row[km]</td>";
     $html .= "<td>$row[evento]</td>";
     $html .= "<td>$row[adblue]</td>";
     $html .= "<td>$row[targa]</td>";
     $html .= "<td>$row[note]</td>";
     $html .= '</tr>';
    }

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3
    grazie

    cmq avevo risolto anche facendo così ma modifico subito riprendendo il mio primo codice, lo preferisco

    codice:
    while($row=mysql_fetch_array($sql))
    {
     echo '<tr>';
     echo '<td>' . $row["ora"] . '</td>';
     echo '<td>' . $row["luogo"] . '</td>';
     echo '<td>' . $row["km"] . '</td>';
     echo '<td>' . $row["evento"] . '</td>';
     echo '<td>' . $row["adblue"] . '</td>';
     echo '<td>' . $row["targa"] . '</td>';
     echo '<td>' . $row["note"] . '</td>';
     echo '</tr>';
    }

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.