Solved

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

Posted on 2011-09-22
2
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Garry Glendown 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 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