Ciao a tutti, ho un piccolo problema che non riesco a risolvere, devo fare la somma del prezzo di tutti gli articoli di quel cliente come faccio?
Devo creare una query con relazioni e che mi somma tali prezzi articoli?
Codice PHP:
<?php require_once("config.inc.php");?>
<?php
$cli_id = $_GET['cli_id'];
$job_id = $_GET['job_id'];
mysql_select_db($database_name, $conn) or die (mysql_error());
$sql = "SELECT * FROM tb_clienti WHERE tb_clienti.cli_id = $cli_id";
$query = mysql_query($sql) or die (mysql_error());
$righe_risultato = mysql_fetch_assoc($query);
mysql_select_db($database_name, $conn) or die (mysql_error());
$sql1 = "SELECT * FROM tb_lavori, tb_articoli, tb_job WHERE tb_job.job_id = tb_lavori.job_id AND tb_articoli.art_id = tb_lavori.art_id AND tb_job.job_id = $job_id";
$query1 = mysql_query($sql1) or die (mysql_error());
$righe_risultato1 = mysql_fetch_assoc($query1);
?>
<!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=iso-8859-1" />
<title>Dettagli lavoro</title>
</head>
<body>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200">Data</td>
<td width="500"><?php echo $righe_risultato1['job_date'];?></td>
</tr>
<tr>
<td valign="top"></td>
<td></td>
</tr>
<tr>
<td valign="top">Lavori eseguiti </td>
<td><table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50">Art ID </td>
<td width="300">Art Descrizione </td>
<td width="50">Prezzo</td>
</tr>
</table>
<?php do{;?><table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50"><?php echo $righe_risultato1['art_id'];?></td>
<td width="300"><?php echo $righe_risultato1['art_descrizione'];?></td>
<td width="50"><?php echo $righe_risultato1['art_prezzo'];?>.- </td>
</tr>
</table>
<?php } while ($righe_risultato1 = mysql_fetch_assoc($query1));?>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50"></td>
<td width="300"><div align="right">Totale: </div></td>
<td width="50">[COLOR=red]Qui il totale ma come?[/COLOR]</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Grazie anticipatamente Michel