Jump to content
MakeWebGames

Donation logs


BluroSoft
 Share

Recommended Posts

I need some help with my donation logs.

Basically i want to view my total donation for last month can some help me code this in. I have tried this no result being displayed.

$blah=$db->query("SELECT SUM(payment) as total_payment FROM donations WHERE timestamp BETWEEN DATE_ADD( now( ) , INTERVAL -1 MONTH ) AND now() ");
$blah->fetchInto($row);
echo $row['total_payment'];

 

this is my current script (Mccodes v2)

function view_donation_logs()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 2)
{
die("403");
}
$_GET['st']=abs((int) $_GET['st']);
$rpp=100;
print "<h3>Donation Logs</h3>
<table width=100% cellspacing='1' class='table'> \n<tr style='background:gray'> <th>Time</th> <th>User</th> <th>Amount</th> <th>Item</th> <th>Qty</th> </tr>";
$q=$db->query("SELECT * FROM donations AS s LEFT JOIN users AS u ON s.buyer=u.userid ORDER BY s.id DESC LIMIT {$_GET['st']},$rpp ");
while($r=$db->fetch_row($q))
{
print "<tr><td>".date('F j Y g:i:s a', $r['timestamp'])."</td><td><a href=#viewuser.php?u={$r['buyer']}>{$r['username']}</a> [{$r['buyer']}]</td><td>\${$r['payment']}</td><td>{$r['item']}</td><td>{$r['quantity']}</td></tr> ";
}

print"</table><br />";
$mypage=floor($_GET['st']/$rpp)+1;
$q2=$db->query("SELECT id FROM stafflog");
$rs=$db->num_rows($q2);
$pages=ceil($rs/$rpp);
print "Pages: ";
for($i=1;$i<=$pages;$i++)
{
$st=($i-1)*$rpp;
print "<a href='staff_logs.php?action=dlogs&st=$st'>$i</a> ";
}
stafflog_add("Looked at the donation logs");
}
Link to comment
Share on other sites

I PM'd you this:

$time=strtotime("-1 month");

$qm=$db->query("SELECT payment FROM donations WHERE timestamp>={$time}");

while($rm=$db->fetch_row($qm))

{

$total+=$rm['payment'];

}

echo "Donations: \$".money_formatter($total,"").". <br />";

 

Basically, as I stated in another thread, if you think good and hard most of everything you need is in the mccode script, I took the part of cash that is circulated in the game, that counted all money, and used it adding WHERE timestamp>={$time} ...

$time=strtotime("-1 month"); Is docking off 31 days, from today's date, leaving only record payments showing from Jan, 2 2013 - Feb 2nd 2013...

Edited by lucky3809
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...