473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

php mysql report month and ytd

I want to create a report that shows month totals and year to date
totals together but do not know how to go about it. This is what I
have so far to get the month totals:

$date = '20041101000000';

$date1 = '20041201000000';

$result = mysql_query("select a1.part Part, sum(a1.quantity)
Totalordered from a1 where a1.datesold > $date and a1.datesold < $date1
group by a1.part");

echo "<table>";

while ($row = mysql_fetch_row($result)) {
echo "<tr>";
for ($i=0; $i<mysql_num_fields($result); $i++) {
echo "<td>";
echo "<font face='arial,helvetica' font
size='1'>$row[$i]</font>";

echo "</td>";
}
echo "</tr>\n";
}

echo "</table>";

This displays the month totals fine but I want to add a column next to
the month and call it YTD with a different date range. Any ideas?

Jul 17 '05 #1
2 2658
On 21 Dec 2004 06:01:55 -0800, "chubbywillie55" <wi******@yahoo.com> wrote:
I want to create a report that shows month totals and year to date
totals together but do not know how to go about it. This is what I
have so far to get the month totals:

$date = '20041101000000';

$date1 = '20041201000000';

$result = mysql_query("select a1.part Part, sum(a1.quantity)
Totalordered from a1 where a1.datesold > $date and a1.datesold < $date1
group by a1.part");

echo "<table>";

while ($row = mysql_fetch_row($result)) {
echo "<tr>";
for ($i=0; $i<mysql_num_fields($result); $i++) {
echo "<td>";
echo "<font face='arial,helvetica' font
size='1'>$row[$i]</font>";

echo "</td>";
}
echo "</tr>\n";
}

echo "</table>";

This displays the month totals fine but I want to add a column next to
the month and call it YTD with a different date range. Any ideas?


From the name of that column YTD would that be "Year to date", i.e. a running
total? If it's a running total of the data displayed, then you could add up in
PHP and display that in another column. If it needs to work off data outside
the range queried, you're going to have to do another SQL query for it.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
Thanks Andy, I will give that a try and create another query.

Jul 17 '05 #3

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

Similar topics

5
by: Albert Ahtenberg | last post by:
Hi, I have a database with a date field. And I would like to see the report grouped by a ceratin month and year, how can I do that without multiple queries? Albert Ahtenberg
0
by: Philip Stoev | last post by:
Hi all, Please tell me if any of this makes sense. Any pointers to relevant projects/articles will be much appreciated. Philip Stoev http://www.stoev.org/pivot/manifest.htm ...
6
by: Wire | last post by:
Hello I want to sum these records on month(datum) and device and get then get the min and max values and the associated low high date/times this does not work select month(datum) as...
1
by: Wayfarer | last post by:
I've built a report using a aggregate query that is grouped by Month + Year, Program and Name. When I feed the date ranges as query parameters, it will very properly print out a report that shows...
0
by: Rahul Chatterjee | last post by:
Hello All I have designed a dotnet application using VB which basically takes a selection and passes value to a crystal report which in turn passes the value to a Stored procedure. After the...
1
by: Andy_Khosravi | last post by:
I'm having trouble building a query to gather the information I need from a table. I need to be able to assemble an inventory report that displays receipts, output, and running inventory from a...
12
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October,...
3
by: gmazza via AccessMonster.com | last post by:
Hi there, I am trying to run a report using a parameter for where the user chooses a month from a combo box. Then on the report, I want it to compare the month to a date field and choose only...
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.