Hey All,
I am stumped. I am setting up a page to display all of my transactions broken down into types. I need to get the total dollar amount for each Trans Type and total amount of each transtype. by month and by day
if(isset($_POST['month'])){
$qmonth = $_POST['month'];
} else { $qmonth = date(n);}
if(isset($_POST['year'])) {
$qyear = $_POST['year'];
}
$daysinmnth = date(t);
for($i=1;$i<=$daysinmnth;$i++)
{
$sql1 = mysql_query("select count(id) as TotAut, sum(m_amount) as TotAAut,m_txn_subtd FROM txn_cust_info where m_status='AUTH' and MONTH(m_txn_subtd) = '".$qmonth."' and YEAR(m_txn_subtd) = '".$qyear."' and DAY(m_txn_subtd) = '".$i."' and m2020_id = '".$_SESSION['m2020_id']."'");
$sql2 = mysql_query("select count(id) as TotCap, sum(m_amount) as TotACap,m_txn_subtd FROM txn_cust_info where m_status='CAPT' and MONTH(m_txn_subtd) = '".$qmonth."' and YEAR(m_txn_subtd) = '".$qyear."' and DAY(m_txn_subtd) = '".$i."' and m2020_id = '".$_SESSION['m2020_id']."'");
$sql3 = mysql_query("select count(id) as TotDec, sum(m_amount) as TotADec,m_txn_subtd FROM txn_cust_info where m_status='DECL' and MONTH(m_txn_subtd) = '".$qmonth."' and YEAR(m_txn_subtd) = '".$qyear."' and DAY(m_txn_subtd) = '".$i."' and m2020_id = '".$_SESSION['m2020_id']."'");
$sql4 = mysql_query("select count(id) as TotRev, sum(m_amount) as TotARev,m_txn_subtd FROM txn_cust_info where m_status='REVR' and MONTH(m_txn_subtd) = '".$qmonth."' and YEAR(m_txn_subtd) = '".$qyear."' and DAY(m_txn_subtd) = '".$i."' and m2020_id = '".$_SESSION['m2020_id']."'");
$sql5 = mysql_query("select count(id) as TotChb, sum(m_amount) as TotAChb,m_txn_subtd FROM txn_cust_info where m_status='REVR' and MONTH(m_txn_subtd) = '".$qmonth."' and YEAR(m_txn_subtd) = '".$qyear."' and DAY(m_txn_subtd) = '".$i."' and m2020_id = '".$_SESSION['m2020_id']."'");
$auth_arr = mysql_fetch_array($sql1);
$cap_arr = mysql_fetch_array($sql2);
$dec_arr = mysql_fetch_array($sql3);
$rev_arr = mysql_fetch_array($sql4);
$chb_arr = mysql_fetch_array($sql5);
}
?>
I am getting Invalid MySQL_resource. If I chop all the date stuff off it actually works but for all the data in the database not daily totals or monthly totals.
Is there a better way to do this?? and my main issue is just extracting data for each day of a specific month as I look at back months alot.
thx for any pointers
Eric