Solved

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

Posted on 2011-09-22
2
342 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
htaccess block all countries but the US 4 41
PHP Curl Problem 10 42
How do i use the await event in php echo 5 19
T-SQL: How to extract records into a new table 7 21
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
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.

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