need help with a query...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

need help with a query...

Post by Burrito »

I have users in a phonelog database that I need to generate some logs for.

I have two tables set up for this. One is a list of users with their extensions, departments, and names. The other is the actual phone records that our PBX dumps into MySQL. I need to be able to get a total by each user (both inbound and outbound) as well as a total by department.

here's what I have so far:

Code: Select all

$deptsqlin = "select l.*, e.name from logs l, extensions e where (cast(concat(l.year,'-',l.month,'-',l.date) as DATE) between '".date("Y-m-d", strtotime($y."-".$m."-".$d))."' and '".date("Y-m-d", strtotime($ty."-".$tm."-".$td))."') and l.dest_mail = e.ext and e.department = '".$dept."'";
that obviously doesn't group them by anything rather it just spits out each individual record for each record on the phone records table. I'm certain that I could do all my math with php, but I'm thinking there's got to be a way to just do it with the sql and then dump it out onto my page. I'm not worried about outbound vs inbound at this point, but if you can help me just figure out a way to group by each user, and then a total tally for each department, that'd be great.

thx,

Burr


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Post Reply