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'] == 1 )
{
$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'] == 1 )
{
$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