Hello all I have a helpdesk application that was written in php and I 
would like to create a script that will e-mail the systems staff how many 
open helpdesk tickets they have.  There are 10 users and I can wrtie a 
script no problem to do a count and then e-mail that to a user I just have 
no idea how the heck to loop it through all of the users .....

Here is my code for one user if they are logged in if anyone can help me 
or lead me in the right direction I would appreicate it very much my brain 
is just not working today:


function showSummary() {
   global $user, $mysql_link;
   $openTickets = 0;
   $userTickets = 0;
 
   $query = "SELECT events.e_id, events.t_id, events.e_status, " .
            "events.e_assignedto, ticket.t_id FROM events,ticket " .
            " WHERE events.t_id = ticket.t_id ORDER BY " .
            " events.t_id, events.e_id;";
   $result = query( $query );

   $row = mysql_fetch_row( $result );

   $prev_e_id = $row[0]; 
   $prev_t_id = $row[1]; 
   $prev_e_status = $row[2]; 
   $prev_e_assignedto = $row[3];

   $done = 0;
   while( !$done  ) {
       $row = mysql_fetch_row( $result );
       if( !$row ) { 
           $done = 1;
       }
 
       $e_id = $row[0]; 
       $t_id = $row[1]; 
       $e_status = $row[2]; 
       $e_assignedto = $row[3];

       if( $t_id != $prev_t_id ) {
           if( $prev_e_status == "OPEN" ) {
               $openTickets++;
               if( $prev_e_assignedto == $user && isset($user) )
                   $userTickets++;
           }
       }
 
       $prev_e_id = $e_id;
       $prev_t_id = $t_id;
       $prev_e_status = $e_status;
       $prev_e_assignedto = $e_assignedto;
   }
 
   print "Open Tickets: $openTickets<br>\n";
   print "Assigned to you: $userTickets<br>\n";
}

Reply via email to