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 (1204 Views)
| Please Help!!! Sum 2 Or More Same ID Within A Date Range by nicolas247(op): 5:25am On May 02, 2018*. Modified: 5:45am 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 " ;$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: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: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: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. |
I Need suggestion On Which Laptop To Buy Between Range Of 200-220k • 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
Introduction To HTML • The Best Place To Get UK/US Used Apple Macbook Pro Laptops In Lagos/nigeria • Needs A Registration Page With A Form Print Out
;