how to sum the total of the column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dreamy
    New Member
    • Jul 2009
    • 29

    how to sum the total of the column

    dear all,
    can some 1 help me in saving the problem of

    total all the amount
    and print in a table form with all the detail?
    using php and mysql.

    thz.
  • vikas1111
    New Member
    • Feb 2008
    • 122

    #2
    Originally posted by dreamy
    dear all,
    can some 1 help me in saving the problem of

    total all the amount
    and print in a table form with all the detail?
    using php and mysql.

    thz.
    Can you be more specific ?

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      tip: check out MySQL's SUM() function.

      Comment

      • dreamy
        New Member
        • Jul 2009
        • 29

        #4
        ok,
        i have try
        <?
        total=0;
        $total += $row['amount'];
        print $total;
        ?>

        and it can total up all the value.
        but it print every line.

        how can i print under the column?

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          Originally posted by dreamy
          and it can total up all the value.
          but it print every line.
          if you put the print command inside the while loop that's only natural.

          using the sum() function in your sql query prevents that because you only have one "row".

          Comment

          • dreamy
            New Member
            • Jul 2009
            • 29

            #6
            ok, i try it.
            thz dormilich

            Comment

            Working...