Solved

PHP MySQL Report Output separate HTML table for each "Client"

Posted on 2011-09-22
2
341 Views
Last Modified: 2012-08-14
I have a bill tracking website with a report function in PHP with a drop-down menu of all clients in the database. Currently, the user selects the appropriate client and fires a query that populates the report with that client's information in a nice table format.

I would like to build a similar function, but one that includes ALL clients in the report. The caveat is that I would like each client to be broken out separately, each with their own "table" of billing entries.

Basically, I want to take each "individual client report" and stack them all together into one report.

I can't seem to figure out how to make this work, however. My current query (for the individual report) is:

if ($submit) {
$ccc = $client;
$result = mysql_query("SELECT billing.*, client.* FROM billing, client WHERE billing.client = client.id HAVING billing.client = $ccc ORDER by date asc ");

Open in new window


I can modify that, obviously, to include ALL clients, but they're not broken out and grouped by client. I'm not familiar enough with query modifiers (tried GROUP BY, but no luck), and the script that I'm using doesn't make it any easier.

I'm attaching the entire php page so you can see what I'm working with:
report.php.txt

I'm also attaching a screenshot of what the current (individual) report looks like:  Individual Statement
As well as a graphic of what I am seeking to accomplish:
Individual Statement
Any advice or suggestions would be greatly appreciated!
 
Thanks,
Chris
statement-group.png
0
Comment
Question by:goodie069
2 Comments
 
LVL 17

Accepted Solution

by:
Garry-G earned 500 total points
ID: 36583150
Dropping the "having" clause, and adding the client.id before date should do the job ... on your PHP code, make sure the loop remembers the last client id (set to an impossible value before the loop), then when the data fetched has a different client id, finish the last report (if the old client id is something different from the impossible value), then clear sums etc, start a new report. After the loop, if the last client id is nt the impossible value, repeat the finish report block ...
0
 

Author Closing Comment

by:goodie069
ID: 36590417
Thanks for pointing me in the right direction! Worked like a charm.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question