Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2002
    Messaggi
    12

    Refresh automatico di alcuni elementi della tabella

    Ciao a tutti,

    Ho un problema che mi sta facendo uscire pazzo con il sito che sto creando, una pagina php che si appogia ad un database mysql.
    In pratica quello che faccio è di eseguire una query e di visualizzare i dati in una tabella.
    Quello che vorrei fare è che ogni secondo, solo alcuni elementi della tabella vengano aggiornati automaticamente.
    Quello che sono riuscito a fare è di aggiornare l'intera tabella, qualcuno riesci a darmi un suggerimento per non ricaricare tutta la tabella?

    il codice è il seguente (riporto la parte problematica)
    test.php:
    codice:
    <script type="text/javascript" > 
    $(document).ready (function () { var updater = setInterval (function () { 
    $('#center').load ('status.php', 'update=true'); }, 
    1000); }); 
    </script> 
    
     
    <div id="center"> 
    <?php echo $tbl; ?> 
    
    </div>
    status.php:
    Codice PHP:
    <?php

    // Include the connection mudule
    // Creation connection to the database

    include ('database/connection.php');

    // retrive the information
    $data mysql_query("SELECT * FROM TEST_TABLE ORDER BY TEST_ID DESC") or die(mysql_error()); 

    // Init the tbl variable
    // It will contains the html code

    $tbl '';
    $tbl .= "
    <table>
    <table class=\"table1\">
        <thead>
            <tr>
                <th></th>
                <th scope=\"col\" abbr=\"CH_NAME\">TEST NAME</th>
                <th scope=\"col\" abbr=\"MENU\">MENU</th>
                <th scope=\"col\" abbr=\"VS1_STATUS\">TEST STATUS 1</th>
                <th scope=\"col\" abbr=\"Deluxe\">TEST STATUS 2</th>
            </tr>
        </thead>
        <tbody>"
    ;


    // Retrive the following information 
    // TEST_ID, NAME, TEST_STATUS1, TEST_STATUS2

    while($info mysql_fetch_array$data )) { 
    $tbl .= "<tr>"
    $tbl .= "<th scope=\"row\">".$info['TEST_ID']. "</th>";
    $tbl .= "<td>".$info['TEST_NAME'] . "</td> ";
    $tbl .= " <td><div id=\"accordion\"><div class=\"item\"><a href=\"#\">Menu</a>
                    [*]<a href=\"./\">FUN_1</a>
                    [*]<a href=\"./\">FUN_2</a>
                        </div>
                        </td>"


    if ( 
    $info['TEST_STATUS1'] == )
    {
    $tbl .= " <td id=\"status\"><img src=\"icons/error.png\" width=\"30\%\"></td>";

    else
    {
    $tbl .= " <td id=\"status\"><img src=\"icons/ok.png\" width=\"30\%\"> </td>"
    }

    if ( 
    $info['TEST2'] == )
    {
    $tbl .= " <td id=\"status\"><img src=\"icons/error.png\" width=\"30\%\"></td>";

    else
    {
    $tbl .= " <td id=\"status\"><img src=\"icons/ok.png\" width=\"30\%\"></td>"
    }
    $tbl .= "</tr>";

    $tbl .= "</tbody></table>"

    mysql_close($cxn);

    if (isset (
    $_GET['update']))
    {
        echo 
    $tbl;
        die ();
    }
    ?>
    Quello che vorrei è che solamente le colonne TEST_STATUS1 e TEST_STATUS2 vengano aggiornate.

    Grazie mille per l'aiuto,

    PAZZE

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Be ma se pagina status.php stampa una tabella quello strutturi quello avrai devi sviluppare una pagina che aggiorni solo TEST_STATUS1 e TEST_STATUS2 e anche gli id dovranno essere status1 e status2
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

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.