IT Community - Software Programming, Web Development and Technical Support

how to SUM output of certain field result

This is a discussion on how to SUM output of certain field result within the PHP Programming forums, part of the Web Development category; I got 3 combo box for choose driver,vehicleno and month. OUTPUT id date driver vehicleno drop 3 2005-06-...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 06-22-2009, 12:24 AM
sasikashiroshi sasikashiroshi is offline
D-Web Trainee
 
Join Date: Jun 2009
Posts: 2
sasikashiroshi is on a distinguished road
Default how to SUM output of certain field result

I got 3 combo box for choose driver,vehicleno and month.

OUTPUT
id date driver vehicleno drop

3 2005-06-06 sugu 3411 7
9 2007-01-25 sugu 3411 55
10 2007-01-15 sugu 3411 9
11 0000-00-00 sugu 3411 5


i want to SUM the output of this DROP field result. my coding is below, please someone can help me to find solution for this problem. My coding is below...please advise where to add in the fomula / coding.


index.php

<div align="left">
<p><img src="logo.gif" width="78" height="78">
</p>

<?php

// get variable after selecting something from the dropdown with name 'chooser'
$select = $_POST['select'];

// if something has been chosen
if (!empty($select)) {

// get the chosen value
$chooser = $_POST['chooser'];
$chooser2 = $_POST['chooser2'];
$chooser3 = $_POST['chooser3'];

// do whatever u want with that value
// for example output it
print "<B>Displaying Records for : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Driver $chooser</B><P>";
print "Vehicle No: $chooser2 <br>";
print "Month : $chooser3 <P>";

}

$db="b31_209797_pamross";
$link = mysql_connect("","","");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "select * from dt_tb where driver='$chooser' and vehicleno='$chooser2' and month(startdate) between '$chooser3' and '$chooser3' " )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=800 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
__________________
Learning software I AngioplastyI Why
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 06-22-2009, 02:33 AM
maneetpuri maneetpuri is offline
D-Web Trainee
 
Join Date: Feb 2009
Posts: 7
maneetpuri is on a distinguished road
Default Re: how to SUM output of certain field result

Hi,

First define a temp variable and set its value to zero.

Now in the foreach loop, put a if condition that if the name of the field is "drop" then add its value in a temp variable.

After the while is over you will see that the temp variable now has the sum of the drop field.

Hope this helps.

Cheers,

~Maneet
__________________
Maneet Puri
Web Design Company / Data Processing Services
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 07-06-2009, 06:37 AM
gold4282 gold4282 is offline
D-Web Trainee
 
Join Date: Jun 2009
Posts: 8
gold4282 is on a distinguished road
Wink Come here!

Welcpme to here

Last edited by arjkhanna : 09-25-2009 at 04:53 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I print my output? S.Vinothkumar C and C++ Programming 2 10-12-2007 11:46 PM
export java program result into excel chandana Java Server Pages (JSP) 1 09-14-2007 07:08 AM
Use of Text output value Shanthi Testing Tools 1 08-25-2007 01:37 AM
Info on Supplement Result vadivelanvaidyanathan Google 0 05-22-2007 01:56 AM
Any tool to get the Search Engine result montyauto Search Engine Optimization 4 04-22-2007 11:10 PM


All times are GMT -7. The time now is 06:04 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0