ho provato cosi
ma mi restituisce 0 non è possibile che la somma è 0
ma nel campo i dati sono questi
0.00
5.00
5.20
58.00
18.00
5.00
5.00
5.00
5.00
5.00
5.00
5.00
e la struttura della tabella è cosi
codice:
CREATE TABLE `temporaneo` (
`id` int(11) NOT NULL auto_increment,
`articolo` varchar(255) NOT NULL default '',
`quantita` varchar(50) NOT NULL default '',
`prezzo` decimal(11,2) NOT NULL default '0.00',
PRIMARY KEY (`id`)
)
codice:
<?php
function temporanea($conn,$articolo,$quantita,$prezzo){
if ($articolo != "" AND $quantita != "" AND $prezzo != ""){
$inserisco = ("INSERT INTO temporaneo (articolo,quantita,prezzo)VALUES('$articolo','$quantita','$prezzo')");
$inserimento = mysql_query($inserisco, $conn) or die(mysql_error());
header("Location:nuovo.php");
}else{
$query_temperaneo = "SELECT * FROM temporaneo";
$temperaneo = mysql_query($query_temperaneo, $conn) or die(mysql_error());
$row_temperaneo = mysql_fetch_assoc($temperaneo);
$totalRows_temperaneo = mysql_num_rows($temperaneo);
$somma = "SELECT id, articolo, quantita, SUM(prezzo) as totale FROM temporaneo GROUP BY id"
$somma_totale = mysql_query($somma, $conn) or die(mysql_error());
$row_somma = mysql_fetch_assoc($somma_totale);
echo $row_somma['totale'];
while($row_temperaneo = mysql_fetch_assoc($temperaneo)){
$art = $row_temperaneo['articolo'];
$qua = $row_temperaneo['quantita'];
$pre = $row_temperaneo['prezzo'];
echo $pippo = "<table width=\"190\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\"><tr class=\"style3\"><td width=\"24\"><div align=\"center\" class=\"style13\">".$qua."</div></td><td width=\"77\"><div align=\"center\" class=\"style13\">".$art."</div></td><td width=\"79\"><div align=\"center\" class=\"style13\">€ ".$pre."</div></td></tr></table>";
}
mysql_free_result($temperaneo);
}
}
:master: