473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wrong summation using php to read mysql database

want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:
$query = mysql_query("se lect distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,Job DateTo,endYear, NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Da te('$startdate' ) and JobDateTo=('$en ddate')");

thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!

Aug 21 '07 #1
2 1254
Asembereng wrote:
want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:
$query = mysql_query("se lect distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,Job DateTo,endYear, NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Da te('$startdate' ) and JobDateTo=('$en ddate')");

thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!
Since you're asking how to compose a SQL query, I suggest you try a SQL
newsgroup - like comp.databases. mysql.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Aug 21 '07 #2
On 21 Aug, 13:02, Asembereng <mljarj...@gmai l.comwrote:
want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:

$query = mysql_query("se lect distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,Job DateTo,endYear, NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Da te('$startdate' ) and JobDateTo=('$en ddate')");

thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!
Whilst you should be asking this in an SQL group...

Which of the fields
TimeType, JobDateFrom, endYear, NcType
contains months?

Aug 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1770
by: cocoalearner | last post by:
I am serving a website using apache. All the php and mysql code I have written works, except for one thing. When I try to create a database named M#2 using the following call, no database is created. $db = 'M#2'; $query = "create database '$db'"; $result = @mysql_query($query); I am able to create a database just fine using this technique when it is named other things (such as M$B, or Global1). I am able to create
0
2156
by: Hugo Fjelsted Alrøe | last post by:
I am fairly new at MySQL, so please excuse any ignorance. We are using MySQL (version 3.23.48) in connection with an Eprints = archive. We have non-english deposits in the archive, and non-standard = characters are not always shown right in our system. They are shown = wrong in the subscription alerts that the archive generates and sends = out - this is what annoys us. And they are shown wrong in the database = itself. But they are shown...
0
2748
by: Bennett Haselton | last post by:
I'm trying to port my MySQL tables for a database called "tracerlock" from one server to another. On the old server, in the /var/lib/mysql/tracerlock directory, there was a ".MYD", ".MYI" and ".frm" file for every table in the database. So after creating a database called "tracerlock" on the new server, I copied these files over to the /var/lib/mysql/tracerlock directory on the new server. On both servers, all the table files are owned...
7
33400
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I need to know else (e.g. Navicat)? Thanks Phil
17
2022
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a number 1 that is the value of collumn home_id which is set to auto increment ect ect but this script which gets the id of home_id of a row and lets you edit it does not work for somereason...
1
1410
by: crazydrummer | last post by:
hi everyone, fairly new to access and VBA, but have fundamental knowledge. as part of a college project i am building a database that records "downtime" for machines in a company. the engineering team will be entering the time that the machine broke at and the time production was restarted. i need the database to produce by means of a query the difference between these two times. I then require all of the downtime values to be placed on...
3
2140
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when Record (i) is shown and modified, the change will come to Record (i+1). Can anyone provide suggestion? thanks.
22
2026
by: davy.zou | last post by:
I found the code for a program that is suppose to be able to work out the sumation of i from 1 to a certain integer n. however, when I implemented to code into Visual C++, it doesn't work. The original sample code provided by the website: unsigned int Sum (unsigned int n) { unsigned int result = 0; for (unsigned int i=1; i<=n; i++) { result+=1;
221
367409
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.