Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,003 members, 7,817,964 topics. Date: Sunday, 05 May 2024 at 12:16 AM

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

Nairaland Forum / Science/Technology / Programming / Please Help!!! Sum 2 Or More Same ID Within A Date Range (1107 Views)

Get Instagram Client ID & Client Secret Key For Your Application / How Can I Send Bulk SMS To MTN Numbers With My Sender Id / Please Someone Should Help Vba To Compute The Product And Sum Of H.C.F And L.C.M (2) (3) (4)

(1) (Reply) (Go Down)

Please Help!!! Sum 2 Or More Same ID Within A Date Range by nicolas247(m): 5:25am On May 02, 2018
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(m): 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(m): 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(m): 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)

Boost Your Programming Skill In Hivazinc Institute's BOOTCAMP 2018 / . / Create And Upload Your App On Play Store !!!(CLOSED)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.