<?php
$sql = "SELECT *  FROM ordini WHERE cliente=$cliente";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
?>
<p><<4-track_ordini>>:</p>

<table border="0" cellspacing="1" cellpadding="2">
  <tr bgcolor="<<1-colore1>>"> 
    <td><b><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1><<4-track_codice>></font></b></td>
    <td nowrap><b><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1><<4-track_data>></font></b></td>
    <td nowrap><b><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1><<4-track_importo>></font></b></td>
    <td nowrap width="100%"><b><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1><<4-track_note>></font></b></td>
  </tr>
  <?php
	$sql = "SELECT ordini.* , DATE_FORMAT(data, '%d/%m/%Y %H.%i') AS data2 FROM ordini WHERE cliente=$cliente ORDER BY ordini.ID DESC";
	$result = mysql_query($sql);
	while ($row = mysql_fetch_array($result)) {
		$ordid = $row["ID"];
		$codice = htmlentities($row["codice"]);
		$data = htmlentities($row["data2"]);
		$status = $row["status"];
		$totale = htmlentities(number_format($row["totale_lordo"],2,",","."));
		$track = nl2br(htmlentities($row["track"]));
		if ($sfondo == '<<1-colore2>>') {
			$sfondo = '<<1-colore3>>';
		} else {
	    	$sfondo = '<<1-colore2>>';
		}
?>
  <tr align="left" valign="top" bgcolor="<?php echo $sfondo; ?>"> 
    <td><b><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1> 
      <?php echo $codice; ?></font></b> </td>
    <td nowrap><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1> 
      <?php echo $data; ?></font>
    </td>
    <td nowrap align="right"><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1> 
      <?php echo $totale; ?>
      </font> </td>
    <td width="100%"><font color="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1> 
      <?php echo $track; ?></font>
      </td>
  </tr>
  <?php
	}
?>
</table>
<?php
} else {
?>
  <<4-track_no_ordini>> 
  <?php
}
?>
