Loading ...
Sorry, an error occurred while loading the content.
 

Re: [phpXperts] Adding total in 2 different Table

Expand Messages
  • Mety Soriano
    Thank you so much sir, it helps me a lot.. Thank you so much for your great help.   Thank you and GOD bless METY  R. SORIANO IT Administrator Sacred Heart
    Message 1 of 5 , Mar 31, 2009
      Thank you so much sir, it helps me a lot.. Thank you so much for your great help.
       
      Thank you and GOD bless

      METY  R. SORIANO
      IT Administrator
      Sacred Heart College
      1 Merchan Street
      Lucena City, Quezon
      Philippines

      (+63)9282860545
      (042)3736167
      http://www.shc.edu.ph


      --- On Tue, 31/3/09, arup barua <arupbarua_06@...> wrote:
      From: arup barua <arupbarua_06@...>
      Subject: Re: [phpXperts] Adding total in 2 different Table
      To: phpexperts@yahoogroups.com
      Date: Tuesday, 31 March, 2009, 1:06 PM

      Hi;
          first of all   $addcolumn = "SELECT SUM(sub_total_ finance) FROM snhf_expense_ finance, SELECT SUM(sub_total_ misc) FROM snhf_expense_ misc"; this is not a correct syntax to execute mysql_query. Try out with the following.Hope this will work fine.

      <?php
      $total = $sub_total_misc + $sub_total_finance;
      $open_record = "SELECT * from snhf_expense_ misc ORDER by recno DESC";
      $open_query = mysql_query( $open_record, $dbaseconnect) ;

      $open_record1 = "SELECT * from snhf_expense_ finance ORDER by recno DESC";
      $open_query1 = mysql_query( $open_record, $dbaseconnect) ;

      $addcolumn = "SELECT a.total AS sub_total_misc ,b.total AS sub_total_                    finance,SUM( a.total+ b.total) AS total
                    FROM   (SELECT SUM(sub_total_ finance) AS total FROM snhf_expense_ finance) AS a,
                           (SELECT SUM(sub_total_ misc) AS total FROM snhf_expense_ misc) AS b;";

      $result    = mysql_query( $addcolumn, $dbaseconnect) ;
      $myCal     = mysql_fetch_ object($result) ;
      ?>
      <font size="3" face="arial" ><div align="center" >Total Expenses ==>
      &nbsp;&nbsp;
      <strong>P<?php echo number_format( $myCal->sub_total_misc, 2) ?>;
      <strong>P<?php echo number_format( $myCal->sub_total_ finance,2);
      echo $myCal->total;
      ?>
                                                                                                          Regards
                                                                                                            Arup              

      --- On Tue, 31/3/09, metysoriano <metysoriano@ yahoo.com> wrote:
      From: metysoriano <metysoriano@ yahoo.com>
      Subject: Re: [phpXperts] Adding total in 2 different Table
      To: phpexperts@yahoogro ups.com
      Date: Tuesday, 31 March, 2009, 3:10 AM

      Below is my code, BUt it does not work

      <?php
      $total = $sub_total_misc + $sub_total_finance;
      $open_record = "SELECT * from snhf_expense_ misc ORDER by recno DESC";
      $open_query = mysql_query( $open_record, $dbaseconnect) ;

      $open_record1 = "SELECT * from snhf_expense_ finance ORDER by recno DESC";
      $open_query1 = mysql_query( $open_record, $dbaseconnect) ;

      $addcolumn = "SELECT SUM(sub_total_ finance) FROM snhf_expense_ finance, SELECT

      SUM(sub_total_ misc) FROM snhf_expense_ misc";

      $query = mysql_query( $addcolumn, $dbaseconnect) ;

      while ($total = mysql_fetch_ array($query) )
      {
      ?>
      <font size="3" face="arial" ><div align="center" >Total Expenses ==>
      &nbsp;&nbsp;
      <strong>P<?php echo number_format( $total['SUM (sub_total_misc) '],2) ?>;
      <strong>P<?php echo number_format( $total['SUM( sub_total_ finance)' ],2);
      }

      echo $total;
      ?>

      THANK YOU IN ADVANCE YOUR HELP

      --- In phpexperts@yahoogro ups.com, arup barua <arupbarua_06@ ...> wrote:
      >
      > Hi;
      >       Try out with this.If i gott u then this would be efficient instead of INNER JOIN........ ...
      >
      >       SELECT SUM(a.total+ b.total) AS total
      >       FROM (SELECT SUM(fieldName) AS total FROM tableName whereClauseIfAny) AS a,
      >       (SELECT SUM(fieldName) AS total FROM tableName whereClauseIfAny) AS b;
      >                                                                                                       
      >                                                                                                              Regards
      >                                                                                                                 Arup
      > --- On Thu, 26/3/09, metysoriano <metysoriano@ ...> wrote:
      > From: metysoriano <metysoriano@ ...>
      > Subject: [phpXperts] Adding total in 2 different Table
      > To: phpexperts@yahoogro ups.com
      > Date: Thursday, 26 March, 2009, 8:19 AM
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > How to add the total in 2 different table. DO I need to use INNER JOIN? Or just add the variable holds the total of table 1 and table 2
      >
      >
      >
      > Please help.
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > Get your preferred Email name!
      > Now you can @... and @rocketmail. com.
      > http://mail. promotions. yahoo.com/ newdomains/ aa/
      >



      Get your new Email address!
      Grab the Email name you've always wanted before someone else does!


      Get your preferred Email name!
      Now you can @... and @....
    Your message has been successfully submitted and would be delivered to recipients shortly.