Get Ledger Report Mysql Table using PHP [closed]












-1















I have inserting mysql table



this my table



ID |VoucherNO|   VoucherType|   AccName         |   Particulars       |   Debit     |    Credit |     Date
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
1 | 1 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 500 | 0 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
2 | 1 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 500 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
3 | 2 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 250 | 0 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
4 | 2 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 250 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|-----------
5 | 3 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 100 | 0 | 2018-nov-27
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
6 | 3 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 100 | 2018-nov-27
-------------------------------------------------------------------------------------------------------------


and i want fetch report mysql table like this



----------------------------------------------------------------------------------------- ---
Date | VoucherNo | VoucherType | Partuclars | debit | credit | Balance
---------------------------------------------------------------------------------------------

2018-nov-25 1 Cash Payment CASH ACCOUNT 500 500
___________________________________________________________________________________________
2018-nov-26 2 Cash Payment CASH ACCOUNT 250 750
___________________________________________________________________________________________
2018-nov-27 3 Cash Payment CASH ACCOUNT 100 850
____________________________________________________________________________________________

total 850 0.00 850


This table received me from the Inventory Software ,but I don't Know Report Query
How will this be done with the PHP and MYSQL










share|improve this question













closed as too broad by RiggsFolly, TylerH, sideshowbarker, jww, eyllanesc Nov 28 '18 at 1:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR

    – RiggsFolly
    Nov 27 '18 at 19:13











  • this is a specification and not a question

    – RiggsFolly
    Nov 27 '18 at 19:14











  • If you want to pass you gotta go to class. Don't skip and then dump homework problems here. You are expected to make an effort. Also see How do I ask homework questions on Stack Overflow.

    – jww
    Nov 28 '18 at 0:55
















-1















I have inserting mysql table



this my table



ID |VoucherNO|   VoucherType|   AccName         |   Particulars       |   Debit     |    Credit |     Date
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
1 | 1 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 500 | 0 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
2 | 1 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 500 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
3 | 2 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 250 | 0 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
4 | 2 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 250 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|-----------
5 | 3 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 100 | 0 | 2018-nov-27
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
6 | 3 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 100 | 2018-nov-27
-------------------------------------------------------------------------------------------------------------


and i want fetch report mysql table like this



----------------------------------------------------------------------------------------- ---
Date | VoucherNo | VoucherType | Partuclars | debit | credit | Balance
---------------------------------------------------------------------------------------------

2018-nov-25 1 Cash Payment CASH ACCOUNT 500 500
___________________________________________________________________________________________
2018-nov-26 2 Cash Payment CASH ACCOUNT 250 750
___________________________________________________________________________________________
2018-nov-27 3 Cash Payment CASH ACCOUNT 100 850
____________________________________________________________________________________________

total 850 0.00 850


This table received me from the Inventory Software ,but I don't Know Report Query
How will this be done with the PHP and MYSQL










share|improve this question













closed as too broad by RiggsFolly, TylerH, sideshowbarker, jww, eyllanesc Nov 28 '18 at 1:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR

    – RiggsFolly
    Nov 27 '18 at 19:13











  • this is a specification and not a question

    – RiggsFolly
    Nov 27 '18 at 19:14











  • If you want to pass you gotta go to class. Don't skip and then dump homework problems here. You are expected to make an effort. Also see How do I ask homework questions on Stack Overflow.

    – jww
    Nov 28 '18 at 0:55














-1












-1








-1








I have inserting mysql table



this my table



ID |VoucherNO|   VoucherType|   AccName         |   Particulars       |   Debit     |    Credit |     Date
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
1 | 1 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 500 | 0 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
2 | 1 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 500 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
3 | 2 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 250 | 0 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
4 | 2 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 250 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|-----------
5 | 3 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 100 | 0 | 2018-nov-27
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
6 | 3 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 100 | 2018-nov-27
-------------------------------------------------------------------------------------------------------------


and i want fetch report mysql table like this



----------------------------------------------------------------------------------------- ---
Date | VoucherNo | VoucherType | Partuclars | debit | credit | Balance
---------------------------------------------------------------------------------------------

2018-nov-25 1 Cash Payment CASH ACCOUNT 500 500
___________________________________________________________________________________________
2018-nov-26 2 Cash Payment CASH ACCOUNT 250 750
___________________________________________________________________________________________
2018-nov-27 3 Cash Payment CASH ACCOUNT 100 850
____________________________________________________________________________________________

total 850 0.00 850


This table received me from the Inventory Software ,but I don't Know Report Query
How will this be done with the PHP and MYSQL










share|improve this question














I have inserting mysql table



this my table



ID |VoucherNO|   VoucherType|   AccName         |   Particulars       |   Debit     |    Credit |     Date
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
1 | 1 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 500 | 0 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
2 | 1 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 500 | 2018-nov-25
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
3 | 2 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 250 | 0 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
4 | 2 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 250 | 2018-nov-26
---|---------|--------------|-------------------|---------------------|-------------|-----------|-----------
5 | 3 | Cash Payment| OFFICE EXPENSE | CASH ACCOUNT | 100 | 0 | 2018-nov-27
---|---------|--------------|-------------------|---------------------|-------------|-----------|------------
6 | 3 | Cash Payment| CASH ACCOUNT | OFFICE EXPENSE | 0 | 100 | 2018-nov-27
-------------------------------------------------------------------------------------------------------------


and i want fetch report mysql table like this



----------------------------------------------------------------------------------------- ---
Date | VoucherNo | VoucherType | Partuclars | debit | credit | Balance
---------------------------------------------------------------------------------------------

2018-nov-25 1 Cash Payment CASH ACCOUNT 500 500
___________________________________________________________________________________________
2018-nov-26 2 Cash Payment CASH ACCOUNT 250 750
___________________________________________________________________________________________
2018-nov-27 3 Cash Payment CASH ACCOUNT 100 850
____________________________________________________________________________________________

total 850 0.00 850


This table received me from the Inventory Software ,but I don't Know Report Query
How will this be done with the PHP and MYSQL







php mysql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 27 '18 at 18:44









safvan safsafvan saf

162




162




closed as too broad by RiggsFolly, TylerH, sideshowbarker, jww, eyllanesc Nov 28 '18 at 1:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as too broad by RiggsFolly, TylerH, sideshowbarker, jww, eyllanesc Nov 28 '18 at 1:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1





    Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR

    – RiggsFolly
    Nov 27 '18 at 19:13











  • this is a specification and not a question

    – RiggsFolly
    Nov 27 '18 at 19:14











  • If you want to pass you gotta go to class. Don't skip and then dump homework problems here. You are expected to make an effort. Also see How do I ask homework questions on Stack Overflow.

    – jww
    Nov 28 '18 at 0:55














  • 1





    Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR

    – RiggsFolly
    Nov 27 '18 at 19:13











  • this is a specification and not a question

    – RiggsFolly
    Nov 27 '18 at 19:14











  • If you want to pass you gotta go to class. Don't skip and then dump homework problems here. You are expected to make an effort. Also see How do I ask homework questions on Stack Overflow.

    – jww
    Nov 28 '18 at 0:55








1




1





Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR

– RiggsFolly
Nov 27 '18 at 19:13





Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR

– RiggsFolly
Nov 27 '18 at 19:13













this is a specification and not a question

– RiggsFolly
Nov 27 '18 at 19:14





this is a specification and not a question

– RiggsFolly
Nov 27 '18 at 19:14













If you want to pass you gotta go to class. Don't skip and then dump homework problems here. You are expected to make an effort. Also see How do I ask homework questions on Stack Overflow.

– jww
Nov 28 '18 at 0:55





If you want to pass you gotta go to class. Don't skip and then dump homework problems here. You are expected to make an effort. Also see How do I ask homework questions on Stack Overflow.

– jww
Nov 28 '18 at 0:55












1 Answer
1






active

oldest

votes


















0














The PHP is probably going to have to do most of the work, so I am going to omit the SQL, but I am assuming a simple SELECT * FROM myTableName ORDER BY VoucherNo; would work (tjhe ORDER BY may not be needed if that is the primary key). I am also using 0 as a starting balance, so adjust that if you need to.



$balance = 0;
$curdate = '';
$output = array();
$curValue = array(
'Date' => '',
'VoucherNo' => 0,
'VoucherType' => '',
'Partuclars' => '',
'debit' => 0,
'credit' => 0,
'Balance' => 0
);

foreach($prePopulatedResultsArray as $row) {

// if the current day is done being populated, add data to output and reset current
if ($curdate !== $row['Date']) {
// only add the current value if it has been populated
if ($curdate !== '')
$output = $curValue;

$curValue = array(
'Date' => $row['Date'],
'VoucherNo' => $row['VoucherNo'],
'VoucherType' => $row['VoucherType'],
'Partuclars' => $row['Partuclars'],
'debit' => $row['debit'],
'credit' => $row['credit'],
'Balance' => $balance + $row['debit']
);
$curdate = $row['Date'];

// if it is still the same day as the last iteration, add to existing values
} else {
$curValue['debit'] = $curValue['debit']+$row['debit'];
$curValue['credit'] = $curValue['debit']+$row['credit'];
$balance = $balance + $row['debit'];
$curValue['Balance'] = $curValue['Balance']+$balance;
}
}


This may be a little off from what you were aiming for because I am basing your output on the fact that you are adding debit to Balance and I am populating credit, even though you had empty values in your expected results. Let me know if the answer needs adjusting.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The PHP is probably going to have to do most of the work, so I am going to omit the SQL, but I am assuming a simple SELECT * FROM myTableName ORDER BY VoucherNo; would work (tjhe ORDER BY may not be needed if that is the primary key). I am also using 0 as a starting balance, so adjust that if you need to.



    $balance = 0;
    $curdate = '';
    $output = array();
    $curValue = array(
    'Date' => '',
    'VoucherNo' => 0,
    'VoucherType' => '',
    'Partuclars' => '',
    'debit' => 0,
    'credit' => 0,
    'Balance' => 0
    );

    foreach($prePopulatedResultsArray as $row) {

    // if the current day is done being populated, add data to output and reset current
    if ($curdate !== $row['Date']) {
    // only add the current value if it has been populated
    if ($curdate !== '')
    $output = $curValue;

    $curValue = array(
    'Date' => $row['Date'],
    'VoucherNo' => $row['VoucherNo'],
    'VoucherType' => $row['VoucherType'],
    'Partuclars' => $row['Partuclars'],
    'debit' => $row['debit'],
    'credit' => $row['credit'],
    'Balance' => $balance + $row['debit']
    );
    $curdate = $row['Date'];

    // if it is still the same day as the last iteration, add to existing values
    } else {
    $curValue['debit'] = $curValue['debit']+$row['debit'];
    $curValue['credit'] = $curValue['debit']+$row['credit'];
    $balance = $balance + $row['debit'];
    $curValue['Balance'] = $curValue['Balance']+$balance;
    }
    }


    This may be a little off from what you were aiming for because I am basing your output on the fact that you are adding debit to Balance and I am populating credit, even though you had empty values in your expected results. Let me know if the answer needs adjusting.






    share|improve this answer




























      0














      The PHP is probably going to have to do most of the work, so I am going to omit the SQL, but I am assuming a simple SELECT * FROM myTableName ORDER BY VoucherNo; would work (tjhe ORDER BY may not be needed if that is the primary key). I am also using 0 as a starting balance, so adjust that if you need to.



      $balance = 0;
      $curdate = '';
      $output = array();
      $curValue = array(
      'Date' => '',
      'VoucherNo' => 0,
      'VoucherType' => '',
      'Partuclars' => '',
      'debit' => 0,
      'credit' => 0,
      'Balance' => 0
      );

      foreach($prePopulatedResultsArray as $row) {

      // if the current day is done being populated, add data to output and reset current
      if ($curdate !== $row['Date']) {
      // only add the current value if it has been populated
      if ($curdate !== '')
      $output = $curValue;

      $curValue = array(
      'Date' => $row['Date'],
      'VoucherNo' => $row['VoucherNo'],
      'VoucherType' => $row['VoucherType'],
      'Partuclars' => $row['Partuclars'],
      'debit' => $row['debit'],
      'credit' => $row['credit'],
      'Balance' => $balance + $row['debit']
      );
      $curdate = $row['Date'];

      // if it is still the same day as the last iteration, add to existing values
      } else {
      $curValue['debit'] = $curValue['debit']+$row['debit'];
      $curValue['credit'] = $curValue['debit']+$row['credit'];
      $balance = $balance + $row['debit'];
      $curValue['Balance'] = $curValue['Balance']+$balance;
      }
      }


      This may be a little off from what you were aiming for because I am basing your output on the fact that you are adding debit to Balance and I am populating credit, even though you had empty values in your expected results. Let me know if the answer needs adjusting.






      share|improve this answer


























        0












        0








        0







        The PHP is probably going to have to do most of the work, so I am going to omit the SQL, but I am assuming a simple SELECT * FROM myTableName ORDER BY VoucherNo; would work (tjhe ORDER BY may not be needed if that is the primary key). I am also using 0 as a starting balance, so adjust that if you need to.



        $balance = 0;
        $curdate = '';
        $output = array();
        $curValue = array(
        'Date' => '',
        'VoucherNo' => 0,
        'VoucherType' => '',
        'Partuclars' => '',
        'debit' => 0,
        'credit' => 0,
        'Balance' => 0
        );

        foreach($prePopulatedResultsArray as $row) {

        // if the current day is done being populated, add data to output and reset current
        if ($curdate !== $row['Date']) {
        // only add the current value if it has been populated
        if ($curdate !== '')
        $output = $curValue;

        $curValue = array(
        'Date' => $row['Date'],
        'VoucherNo' => $row['VoucherNo'],
        'VoucherType' => $row['VoucherType'],
        'Partuclars' => $row['Partuclars'],
        'debit' => $row['debit'],
        'credit' => $row['credit'],
        'Balance' => $balance + $row['debit']
        );
        $curdate = $row['Date'];

        // if it is still the same day as the last iteration, add to existing values
        } else {
        $curValue['debit'] = $curValue['debit']+$row['debit'];
        $curValue['credit'] = $curValue['debit']+$row['credit'];
        $balance = $balance + $row['debit'];
        $curValue['Balance'] = $curValue['Balance']+$balance;
        }
        }


        This may be a little off from what you were aiming for because I am basing your output on the fact that you are adding debit to Balance and I am populating credit, even though you had empty values in your expected results. Let me know if the answer needs adjusting.






        share|improve this answer













        The PHP is probably going to have to do most of the work, so I am going to omit the SQL, but I am assuming a simple SELECT * FROM myTableName ORDER BY VoucherNo; would work (tjhe ORDER BY may not be needed if that is the primary key). I am also using 0 as a starting balance, so adjust that if you need to.



        $balance = 0;
        $curdate = '';
        $output = array();
        $curValue = array(
        'Date' => '',
        'VoucherNo' => 0,
        'VoucherType' => '',
        'Partuclars' => '',
        'debit' => 0,
        'credit' => 0,
        'Balance' => 0
        );

        foreach($prePopulatedResultsArray as $row) {

        // if the current day is done being populated, add data to output and reset current
        if ($curdate !== $row['Date']) {
        // only add the current value if it has been populated
        if ($curdate !== '')
        $output = $curValue;

        $curValue = array(
        'Date' => $row['Date'],
        'VoucherNo' => $row['VoucherNo'],
        'VoucherType' => $row['VoucherType'],
        'Partuclars' => $row['Partuclars'],
        'debit' => $row['debit'],
        'credit' => $row['credit'],
        'Balance' => $balance + $row['debit']
        );
        $curdate = $row['Date'];

        // if it is still the same day as the last iteration, add to existing values
        } else {
        $curValue['debit'] = $curValue['debit']+$row['debit'];
        $curValue['credit'] = $curValue['debit']+$row['credit'];
        $balance = $balance + $row['debit'];
        $curValue['Balance'] = $curValue['Balance']+$balance;
        }
        }


        This may be a little off from what you were aiming for because I am basing your output on the fact that you are adding debit to Balance and I am populating credit, even though you had empty values in your expected results. Let me know if the answer needs adjusting.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 19:16









        mtr.webmtr.web

        1,1961816




        1,1961816

















            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks