Ciao a tutti ragazzi!
Devo sommare tutti i prezzi di un determinato mese.
Dovrebbe essere giusta ma il compilatore mi dice che non va bene.
Idee?Codice PHP:
<?php
$month=$_POST['month']; if($month=="January"){ $month="01"; } if($month=="February"){ $month="02"; } if($month=="March"){ $month="03"; } if($month=="April"){ $month="04"; } if($month=="May"){ $month="05"; } if($month=="June"){ $month="06"; } if($month=="July"){ $month="07"; } if($month=="August"){ $month="08"; } if($month=="September"){ $month="09"; } if($month=="October"){ $month="10"; } if($month=="November"){ $month="11"; } if($month=="December"){ $month="12"; }
//Connection
$link = mysql_connect('localhost', 'xxx', 'xxx');
if (!$link) { die('Could not connect: ' . mysql_error()); }
//Select DB
mysql_select_db(my_idnob) or die ("Error in selection database ".mysql_error());
$query="SELECT SUM(price) as totalmonth FROM clothes WHERE MONTH(date) =". $month;
$result = mysql_query($query) or die ("error in query ".mysql_error()); list($totalmonth) = mysql_fetch_array($result); print $totalmonth;
?>
Grazie in anticipo!