I'm not 100% sure what u mean and I'm no expert myself but I did just finish writing a querry that i think may work for you. You need to use "SUM" and "GROUP BY". This will give you the SUM of a field and GROUP BY whatever field you prefer. Actualy after thinking a bit more you may need to use "COUNT" and "GROUP BY". Do a google search on "MYSQL, COUNT, SUM" and read up on it. Sorry if I have confused you, I'm new to this.
$KTColParam1_purchase_add_credit = "0";
if (isset($_GET["cm"])) {
$KTColParam1_purchase_add_credit = (get_magic_quotes_gpc()) ? $_GET["cm"] : addslashes($_GET["cm"]);
}
mysql_select_db($database_mx_shop, $mx_shop);
$query_purchase_add_credit = sprintf("SELECT orderdetail_ode.idord_ode, sum(products_prd.credits) AS sum_credits_1 FROM (orderdetail_ode LEFT JOIN products_prd ON products_prd.name_prd=orderdetail_ode.pname_ode) WHERE orderdetail_ode.idord_ode='%s' GROUP BY orderdetail_ode.idord_ode ", $KTColParam1_purchase_add_credit);
$purchase_add_credit = mysql_query($query_purchase_add_credit, $mx_shop) or die(mysql_error());
$row_purchase_add_credit = mysql_fetch_assoc($purchase_add_credit);
$totalRows_purchase_add_credit = mysql_num_rows($purchase_add_credit);
|