Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-22
2
Medium Priority
?
349 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 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