Ho fatto qualche prova ma non riesco a farlo funzionare.
In particolare mi viene restituito un errore "Warning: Illegal string offset" che non riesco a correggere.
Ma in ogni caso non riesco ad adattarlo alla mia situazione. Se puoi aiutarmi te ne sarei grato...sono a tua disposizione per qualsiasi info.
Ti metto qui il codice
codice:
<?php
require 'Connections/connetti.php';
mysql_select_db($database_td, $td);
// preparo la query
$query = 'SELECT * FROM demo ORDER BY data DESC';
// invio la query
$result = mysql_query($query);
// controllo l'esito
if (!$result) {
die("Errore nella query $query: " . mysql_error());
}
{ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow">
<link href="css/stile.css" rel="stylesheet" type="text/css">
<title>Gestione Contratti</title>
</head>
<body>
<div id="page-wrap">
<table>
<thead>
<tr>
<td colspan="14" bgcolor="#FFFFFF"><div align="center"><img class="flex" src="logo.png">
<?php include('menu.inc.php'); ?></div>
</td>
</tr>
<tr>
<th>Data</th>
<th>N.</th>
<th>Lang</th>
<th>Auto</th>
<th>Nome Cognome</th>
<th>Test Drive</th>
<th>Doc</th>
<th>Vid</th>
<th>Pas</th>
<th>Paga</th>
<th>Prz</th>
<th>Ant</th>
<th>Saldo</th>
<th>Gestione</th>
</tr>
</thead>
<?php }
// Preparo il valore del colore alternativo delle righe prima del while
$i=1;
//Variabile per controllare la data
$controllo_data = '';
while ($row = mysql_fetch_assoc($result))
{
$data = htmlspecialchars($row['data']);
$lingua = htmlspecialchars($row['lingua']);
$id = htmlspecialchars($row['id']);
$auto = htmlspecialchars($row['auto']);
$nome = htmlspecialchars($row['nome']);
$cognome = htmlspecialchars($row['cognome']);
$telefono = htmlspecialchars($row['telefono']);
$email = htmlspecialchars($row['email']);
$testdrive = htmlspecialchars($row['testdrive']);
$documento = htmlspecialchars($row['documento']);
$docnro = htmlspecialchars($row['docnro']);
$video = htmlspecialchars($row['video']);
$passeggero = htmlspecialchars($row['passeggero']);
$pagamento = htmlspecialchars($row['pagamento']);
$prezzo = htmlspecialchars($row['prezzo']);
$anticipo = htmlspecialchars($row['anticipo']);
// Preparo il link per la modifica dei dati del record
$link = $_SERVER['PHP_SELF'] . '?id=' . $row['id'];
if($i%2 == 1)$color="#eee"; //stampo il primo colore
else $color="#fff"; //altrimenti stampo il secondo colore
{ ?>
<tr bgcolor="<?= $color ?>">
<td><? echo $data; ?></td>
<td><? echo $id; ?></td>
<td><? if ($lingua == '') echo '/'; else echo $lingua; ?></td>
<td><? echo $auto; ?></td>
<td><? echo $nome, $cognome; ?></td>
<td><? echo $testdrive; ?></td>
<td><? echo $documento; ?></td>
<td><? if ($video == 'SI') echo 'SI'; else echo 'NO'; ?></td>
<td><? if ($passeggero == 'SI') echo 'SI'; else echo 'NO'; ?></td>
<td><? echo $pagamento; ?></td>
<td><? echo $prezzo; ?></td>
<td><? if ($anticipo == '') echo '/'; else echo $anticipo; ?></td>
<td><? $saldo = ($prezzo-$anticipo); echo $saldo; ?></td>
<td><a href="<?= $link ?>"><img src="edit.png" border="0" title="modifica" /></a>
<? if ($lingua == 'ita') $stampa="stampa"; else $stampa="print"; ?>
<a href="<?=$stampa?>.php?id=<?=$id?>&nome=<?=$nome?>&cognome=<?=$cognome?>&auto=<?=$auto?>&documento=<?=$documento?>&docnro=<?=$docnro?>&prezzo=<?=$prezzo?>&pagamento=<?=$pagamento?>&testdrive=<?=$testdrive?>&video=<?=$video?>&passeggero=<?=$passeggero?>" target="_blank"><img src="print.png" border="0" title="stampa" /></a></td></tr>
<?php }
$i++;
}
?>
<tr>
<th colspan="14" align="center">Gestione contratti</th>
</tr>
</table>
</div>
</body>
</html>
<?
// libero la memoria di PHP occupata dai record estratti con la SELECT
mysql_free_result($result);
// chiudo la connessione a MySQL
mysql_close();
?>
Ripeto che sono alle prime armi quindi ben vengano anche eventuali osservazioni per indirizzarmi verso una migliore pulizia del codice per evitare errori e incompatibilità..anche se così com'è funziona tutto bene. Mi manca proprio quella divisione dei record per data...
Grazie ancora