Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to Perform addition on row values from DB
Old 05-31-2010, 05:51 AM How to Perform addition on row values from DB
Junior Talker

Posts: 2
Name: Sammie
Trades: 0
Hello

I'm new and i need your help.

I need to create a report using start date and end date.

I created a form that gets the values Between those that and display accordingly unfortunately i need to perform addition on some values.

Date Distributor's ID Customer's Name Total Paid(Naira) Total Paid(Dollar)
2010-05-31 001 Sanyaolu 598,728.00 3,939
Grand Total =N=X $X















Code:
<table width="95%" border="1" align="center" CELLPADDING="2" CELLSPACING="0" bordercolor="<?PHP print "$BorderColour"; ?>">
          <tr valign="middle" class="tableheadsx">
            <td width="91" height="29" align="left" class="welcomexx"><strong>Date</strong></td>
            <td width="136" height="29" align="left" class="welcomexx"><strong>Distributor's ID </strong></td>
			<td width="136" height="29" align="left" class="welcomexx"><strong>Customer's Name </strong></td>
            <td width="140" height="29" align="left" class="welcomexx"><strong>Total Paid(Naira) </strong></td>
			<td width="157" height="29" align="left" class="welcomexx"><strong>Total Paid(Dollar)</strong></td>
          </tr>
		  <?php $rowShine = 1;?>
          <?php if ($totalRows_getPages > 0) { // Show if recordset not empty ?>
            <?php do { ?>
              <tr id="row-<?php echo $row_getPages['code']; ?>" <?php if($rowShine%2){
						echo "class=\"alternate\" ";
					}
			?>><?php $me=$row_getPages['totalDollar']; ?>
			<?php $mee=$row_getPages['totalNaira']; ?>
                <td height="25" align="left" valign="top" class="style1"><?php echo $row_getPages['xdate']; ?></td>
				 <td height="25" align="left" valign="top" class="style1"><?php echo $row_getPages['dis_id']; ?></td>
                <td height="25" align="left" valign="top" class="style1"><strong><?php echo $row_getPages['dis_name']; ?></strong></td>
                <td height="25" align="left" valign="top" class="style1"><?php print number_format($mee,2); ?></td>
				<td height="25" align="left" valign="top" class="style1"><?php print number_format($me); ?></td>
              </tr>
              <tr id="row-<?php echo $row_getPages['code']; ?>" <?php if($rowShine%2){
						echo "class=\"alternate\" ";
					}
			?>>
                <td height="25" align="left" valign="top" class="style1"><strong>Grand Total </strong></td>
                <td height="25" align="left" valign="top" class="style1">&nbsp;</td>
                <td height="25" align="left" valign="top" class="style1">&nbsp;</td>
                <td height="25" align="left" valign="top" class="style1"><img src="http://www.webmaster-talk.com/images/naira.jpg" width="9" height="11" />&nbsp;</td>
                <td height="25" align="left" valign="top" class="style1"><strong>$</strong></td>
              </tr>
              <?php $rowShine++;?>
              <?php } while ($row_getPages = mysql_fetch_assoc($getPages)); ?>
            <?php } // Show if recordset not empty ?>
        </table>

Last edited by fizanos; 05-31-2010 at 07:26 AM..
fizanos is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-31-2010, 07:12 AM Re: How to Perform addition on row values from DB
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Just do that on your sql query.
Code:
select field1+field2 as sumField from yourTable
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-31-2010, 07:38 AM Re: How to Perform addition on row values from DB
Junior Talker

Posts: 2
Name: Sammie
Trades: 0
thanks bro!

The problem is that the table is automatically generated so one can't know the number of field just like in a report
fizanos is offline
Reply With Quote
View Public Profile
 
Old 05-31-2010, 08:29 AM Re: How to Perform addition on row values from DB
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You replace "field1" & "field2" with the actual names of YOUR columns.

It's in 'pseudocode' and field1 & field2 are placeholders
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to How to Perform addition on row values from DB
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20429 seconds with 12 queries