Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8874209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:39:36+00:00 2026-06-14T18:39:36+00:00

So, I have a donation table. It stores a $ value and a column

  • 0

So, I have a donation table. It stores a $ value and a column box where they choose monetary or in kind donation. in-kind donations can have a $ but usually they don’t. An in-kind donation would be if someone donated a physical item ex, lawnmower, table, chair, so on. I then have donors. Finally, I have a Leadership Giving Group. Based on certain amounts a donor gets put into one of the Leadership Giving Groups. So, for $100 the donor is put in Other Donor group, for $1000 they are put in the next one up and so on. I need to sum all the donations but exclude all in kind donations because those(even if they have a monetary value) don’t count for where to place the donor in the Leadership Group.

TABLES: I wasn’t able to do SHOW CREATE because it has a server value that needs to be changed that I don’t control. I hope this is ok for everyone. I just wanted to show the 3 tables and all their current fields . Sorry for the inconvience.

Ok, so for the tables I couldn’t remember all the syntax but it should be easy enough to see the foreign key and Primary Key and all the fields are there. I just am in a bit of a rush as it is Thanksgiving and my family is mad at me for being on the computer.

CREATE TABLE donor (
DonorID INT NOT NULL AUTO_INCREMENT Primary Key,
FirstName VARCHAR(100),
LastName VARCHAR(100),
Street Address VARCHAR(100),
City VARCHAR(100),
State VARCHAR(2),
Zip VARCHAR(5),
Email VARCHAR(100), );

Restriction is 1 of two entries that they select via drop box. Restricted(then it is been designated by donor for a specific project or Non-Restricted meaning donor doesn’t care how the money is used. DonationType works the same way but it is either In-Kind or Monetary. I want to sum just the monetary values

CREATE TABLE donation (
DonationID INT NOT NULL AUTO_INCREMENT Primary Key,
Restriction VARCHAR(10) NOT NULL,
Amount VARCHAR(100) NOT NULL,
Description VARCHAR(2000),
DonationType VARCHAR(100) NOT NULL,
DonorID INT NOT NULL Foreign Key,
DateReceived DATE NOT NULL,

LeadershipGroup Table: I will add when I get done eating, sorry but my family is about to kill me.

LeaderGrp is not a AI, it is a name of each Leaderhip Group: Other Donor, Founder’s Club, Friend’s Circle, and so on. This will always be unique so I made it the PK but if for some reason and AI field I can do that.

I can post my code if that would make it easier but I feel as though it will turn into a huge wall of text for people. However, this is a website and other programming languages I have used in this project are js and php so if it could be possible in php that is an option as well. I could also give you the link the website and let you view the information because currently it is all made up, obviously the real data can’t be shared if that would be helpful. Just ask for it because I didn’t really want to post it when some people might just go in and start adding data to my tables.

Code:

<?php require_once('header.php') ?>
<!--dont modify above this line-->

<?php 
//on ANY page you need to use the database, you need to include the line below ONCE (before doing any db operations)
require_once('connect.php');

function checkAmount($amount, $min, $max)
{
if ($amount >= $min && $amount <= $max)
return true;
else
return false;

} 


//array types of users
$founders_club = array();
$headmasters_circle = array();
$dragons_circle = array();
$green_and_white_society = array();
$seventies_society = array();
$millennium_society = array();
$dome_society = array();
$tunnel_society = array();
$friends_circle = array();
$others = array();

// fiscal year
$currentyear = date("Y");
$selectedyear = $_POST["selectedYear"];
if($selectedyear == "")
$selectedyear = $currentyear;
$startdate = $selectedyear . "-07-01";
$enddate = $selectedyear + 1 . "-06-30";

//we need to put all donors inside the dropdown box, this is how to do it
//the actual query
$result = mysql_query("SELECT * FROM donor;") or die (mysql_error());
echo "<h2>Publication List</h>";
echo "<div>Choose Fiscal Year:";
//this will iterate through every record in the resultset and create an option box
echo "<form id=\"fiscal\" action=\"q1.php\" method=\"POST\">
<select name=\"selectedYear\" onchange=\"document.getElementById('fiscal').submit();\">";
for($i=$currentyear; $i >= 2011; $i--)
{
    if ($i == $selectedyear)
    echo "<option value='".$i."' selected=\"selected\">".$i."</option>";
    else
    echo "<option value='".$i."'>".$i."</option>";
}
echo "</select></form>";
echo "</div><br>";
//this will iterate through every record in the resultset and create an option box
while($row = mysql_fetch_array($result))
{

$result2 = mysql_query("SELECT SUM(DonationAmount) FROM donations Where DonorID = ".$row['DonorID'] . " and donations.Date_Received BETWEEN '" . $startdate . "' and '" . $enddate . "'" ) or die (mysql_error());
    while($row2 = mysql_fetch_array($result2))
        {
        $amount = $row2['SUM(DonationAmount)'];         

        if (checkAmount($amount, 50000, 999999))    
        array_push($founders_club, $row['DisplayName']);

        if (checkAmount($amount, 25000, 49999))
        array_push($headmasters_circle, $row['DisplayName']);

        if (checkAmount($amount, 10000, 24999))
        array_push($dragons_circle, $row['DisplayName']);

        if (checkAmount($amount, 5000, 9999))
        array_push($green_and_white_society, $row['DisplayName']);

        if (checkAmount($amount, 2500, 4999))
        array_push($seventies_society, $row['DisplayName']);

        if (checkAmount($amount, 1000, 2499))
        array_push($millennium_society, $row['DisplayName']);

        if (checkAmount($amount, 500, 999))
        array_push($dome_society, $row['DisplayName']);

        if (checkAmount($amount, 250, 499))
        array_push($tunnel_society, $row['DisplayName']);

        if (checkAmount($amount, 100, 249))
        array_push($friends_circle, $row['DisplayName']);

        if (checkAmount($amount, -1, 99))
        array_push($others, $row['DisplayName']);

        }

}


        //display results
    if(count($founders_club) > 0)   
    {
    echo "<h2>Founder's Club</h2>";
    for ($i = 0; $i < count($founders_club); $i++) 
    echo $founders_club[$i] . "<br>";
    }

    if(count($headmasters_circle) > 0)  
    {
    echo "<h2>Headmaster's Circle</h2>";
    for ($i = 0; $i < count($headmasters_circle); $i++) 
    echo $headmasters_circle[$i] . "<br>";
    }

    if(count($dragons_circle) > 0)  
    {
    echo "<h2>Dragon's Circle</h2>";
    for ($i = 0; $i < count($dragons_circle); $i++) 
    echo $dragons_circle[$i] . "<br>";
    }

    if(count($green_and_white_society) > 0) 
    {
    echo "<h2>Green and White Society</h2>";
    for ($i = 0; $i < count($green_and_white_society); $i++) 
    echo $green_and_white_society[$i] . "<br>";
    }

    if(count($seventies_society) > 0)   
    {
    echo "<h2>1970's Society</h2>";
    for ($i = 0; $i < count($seventies_society); $i++) 
    echo $seventies_society[$i] . "<br>";
    }

    if(count($millennium_society) > 0)  
    {
    echo "<h2>Millennium Society</h2>";
    for ($i = 0; $i < count($millennium_society); $i++) 
    echo $millennium_society[$i] . "<br>";
    }

    if(count($dome_society) > 0)    
    {
    echo "<h2>Dome Society</h2>";
    for ($i = 0; $i < count($dome_society); $i++) 
    echo $dome_society[$i] . "<br>";
    }

    if(count($tunnel_society) > 0)  
    {
    echo "<h2>Tunnel Society</h2>";
    for ($i = 0; $i < count($tunnel_society); $i++) 
    echo $tunnel_society[$i] . "<br>";
    }

    if(count($friends_circle) > 0)  
    {
    echo "<h2>Friends' Circle</h2>";
    for ($i = 0; $i < count($friends_circle); $i++) 
    echo $friends_circle[$i] . "<br>";
    }

    if(count($others) > 0)  
    {
    echo "<h2>Other Donors</h2>";
    for ($i = 0; $i < count($others); $i++) 
    echo $others[$i] . "<br>";      
    }

?>







<!--dont modify below this line-->
<?php require_once('footer.php') ?>

On a side note, I asked a question yesterday and the response was given to me in this nice little box that showed a table name and all of table column headers. Is there a way I can do that in the question so I can maybe illustrate a little better and make my question clearer?

Thanks everyone,

Joel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:39:38+00:00Added an answer on June 14, 2026 at 6:39 pm

    If I understand well, the question is : sum all the “not in-kind” donations for every user to determine in which group they should be added.

    If so, your DB model lacks some foreign keys in order to link donors to their donations, and to LGGs.

    Here’s an example MCD you could use :

    Donor ((PK)DonorId, Address, Phone, (FK -> LGG) LggId)
    Donation((PK)DonationId, (FK -> Donor)DonorId, DonationType, DonationAmount, Description, Date_Received)
    LGG ((PK)LggId, LeaderGrp, LGDescrip, MinAmount)
    

    Where the MinAmount is the minimum amount needed to belong to this group.

    From there, all you have to do is :

    select d.donorid, sum(do.donationamount)
    from donor d,
    donation do
    where d.donorid=do.donorid
    and do.donationtype!='in-kind'
    group by d.donorid
    

    You end up with every donor with the amount they donated in real money.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table Donations which has a CampaignID column that relates to the
I have a table in SQL Server called [Donations] that contains donations given by
I have a Donation.rb model with an amount column that takes an integer. I
I have a donations form in my WordPress blog and the Donation Description is
I have the following code that allows the person to choose the donation amount
I have a radio list to pick a payment value. When you choose the
I have a donations table where I'm trying to calculate the total amount for
I have a data frame with donations and names of donors. **donation** **Donor** 25.00
I am trying to perform to calculation. I have a donations (d) table that
I am working on a donations page where users can enter a donation amount

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.