₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,484 members, 8,422,271 topics. Date: Monday, 08 June 2026 at 01:50 AM

Toggle theme

Please Help!!! Sum 2 Or More Same ID Within A Date Range - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPlease Help!!! Sum 2 Or More Same ID Within A Date Range (1203 Views)

1 Reply (Go Down)

Please Help!!! Sum 2 Or More Same ID Within A Date Range by nicolas247(op):
Please what is wrong with my code

<?php
include('connect.php');
if (isset($_GET["d1"])) { $d1 = $_GET["d1"]; } else { $d1=0; };
if (isset($_GET["d2"])) { $d2 = $_GET["d2"]; } else { $d2=0; };
$result = $db->prepare("SELECT *, SUM(loan_amt), SUM(loan_int), SUM(saving), SUM(total_ded) FROM transaction WHERE trans_date BETWEEN :a AND :b GROUP BY memberId "wink;
$result->bindParam(':a', $d1);
$result->bindParam(':b', $d2);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['memberId']; ?></td>
<td><?php echo $row['trans_date']; ?></td>
<td><?php echo $row['fname']; ?></td>
<td><?php echo $row['SUM(loan_amt)']; ?></td>
<td><?php echo $row['SUM(loan_int)']; ?></td>
<td><?php echo $row['SUM(saving)']; ?></td>
<td><?php echo $row['SUM(total_ded)']; ?></td>

</tr>
<?php
}
?>

What i want to archive is to be able to sum same memberId within a date range please what am i doing wrong
thanks for the help
Re: Please Help!!! Sum 2 Or More Same ID Within A Date Range by nicolas247(op): 1:11pm On May 06, 2018
People just they pass nii
help a brother o

thanks
Re: Please Help!!! Sum 2 Or More Same ID Within A Date Range by Jenifa123: 1:46pm On May 06, 2018
nicolas247:
Please what is wrong with my code

<?php
include('connect.php');
if (isset($_GET["d1"])) { $d1 = $_GET["d1"]; } else { $d1=0; };
if (isset($_GET["d2"])) { $d2 = $_GET["d2"]; } else { $d2=0; };
$result = $db->prepare("SELECT *, SUM(loan_amt), SUM(loan_int), SUM(saving), SUM(total_ded) FROM transaction WHERE trans_date BETWEEN :a AND :b GROUP BY memberId "wink;
$result->bindParam(':a', $d1);
$result->bindParam(':b', $d2);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['memberId']; ?></td>
<td><?php echo $row['trans_date']; ?></td>
<td><?php echo $row['fname']; ?></td>
<td><?php echo $row['SUM(loan_amt)']; ?></td>
<td><?php echo $row['SUM(loan_int)']; ?></td>
<td><?php echo $row['SUM(saving)']; ?></td>
<td><?php echo $row['SUM(total_ded)']; ?></td>

</tr>
<?php
}
?>

What i want to archive is to be able to sum same memberId within a date range please what am i doing wrong
thanks for the help
Are u selecting from a table or wah?
Re: Please Help!!! Sum 2 Or More Same ID Within A Date Range by nicolas247(op): 3:22pm On May 06, 2018
yes am selecting from a table call TRANSACTION
Re: Please Help!!! Sum 2 Or More Same ID Within A Date Range by nicolas247(op): 11:09pm On May 06, 2018
Jenifa123:
Are u selecting from a table or wah?
yes i am
Re: Please Help!!! Sum 2 Or More Same ID Within A Date Range by Jenifa123: 3:31pm On May 07, 2018
nicolas247:
yes i am
U should look at ur query again?
Re: Please Help!!! Sum 2 Or More Same ID Within A Date Range by kudaisi(m): 12:26am On May 09, 2018
You're not stating a problem. Did you try executing the SQL directly in your database engine ? if so, did it work ? If yes, then we can safely assume the problem is from the PHP end of your code. Otherwise, take a second look at your SQL query.

Is your PHP code not producing the desired result ? Or maybe you're not getting any output. Points like this helps narrow down the problem.

Please try and be more specific about what you want.
1 Reply

I Need suggestion On Which Laptop To Buy Between Range Of 200-220kHow Can I Send Bulk SMS To MTN Numbers With My Sender IdPlease Someone Should Help Vba To Compute The Product And Sum Of H.C.F And L.C.M234

How Can I Get Andriod Studio Functional On My PcCreate Your Website With Ease No Code RequiredLearning Programming On Whatsapp