Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8136775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:51:56+00:00 2026-06-06T10:51:56+00:00

I have a simple query (in a mySQL view) that php is using to

  • 0

I have a simple query (in a mySQL view) that php is using to create a table:

select `swtickets`.`ownerstaffid` AS `ID`,
`swtickets`.`ownerstaffname` AS `Owner`,
sum(if((`swtickets`.`ticketstatusid` = 2),1,0)) AS `In Progress`,
sum(if((`swtickets`.`ticketstatusid` = 4),1,0)) AS `Pending Customer`,
sum(if((`swtickets`.`ticketstatusid` = 5),1,0)) AS `Customer Replied`,
sum(if((`swtickets`.`ticketstatusid` = 9),1,0)) AS `Suggested Resolution`,
sum(if((`swtickets`.`priorityid` in (3,6) and `swtickets`.`ticketstatusid` in     (2,4,5,9)),1,0)) AS `High/Critical`,
sum(if((`swtickets`.`ticketstatusid` in (2,4,5,9)),1,0)) AS `Total Workable` 
from `swtickets` where ((`swtickets`.`departmentid` = 14) 
and ownerstaffid in (select staffid from swstaff where staffgroupid=4 and isenabled =  1)
and (`swtickets`.`ownerstaffname` <> '')) group by `swtickets`.`ownerstaffname`

I am calling the data in a while loop, but I can’t seem to get rid of the ‘ID’ column, which I need to call as it serves as the target of the hyperlink for the Owner column. The ideal headers would be:

Owner | In Progress | Pending Customer | Customer Replied | Suggested Resolution | Total Workable

The php:

 $ticketloadquery = mysql_query("SELECT * from open_tickets;")
or die(mysql_error()); 

$ticketloadfield_num = mysql_num_fields($ticketloadquery);

echo "<div><h1>Work Load</h1>";
if(mysql_num_rows($ticketloadquery)==0) {
echo "<i>There are no currently unassigned tickets!</i>";
}
else{
echo "<table border='1'><tr>";
for($i=0; $i<$ticketloadfield_num; $i++)
{
$ticketloadfield = mysql_fetch_field($ticketloadquery);
echo "<td>{$ticketloadfield->name}</td>";
}
echo "</tr>\n";

while($ticketloadinfo = mysql_fetch_array( $ticketloadquery )) 
{ 

echo "<tr>"; 
echo "<td><a href='https://support.mysite.com/staff/dashboard.php?   id=".$ticketloadinfo['ID']."', target='_blank'>".$ticketloadinfo['Owner']."</a></td> "; 
echo "<td>".$ticketloadinfo['Owner'] . "</td> "; 
echo "<td>".$ticketloadinfo['In Progress'] . "</td> "; 
echo "<td>".$ticketloadinfo['Pending Customer'] . " </td>"; 
echo "<td>".$ticketloadinfo['Customer Replied'] . " </td>";
echo "<td>".$ticketloadinfo['Suggested Resolution'] . " </td>"; 

echo "<td>".$ticketloadinfo['Total Workable'] . " </td></tr>"; 
} 
echo "</div>";
echo "</table>"; 
}

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:51:58+00:00Added an answer on June 6, 2026 at 10:51 am

    Even if you manage to make an exception for the ID column now, this approach is going to lead to problems in the future as you are automatically generating your columns from the query for the headers and then you are manually adding columns for the information you want to display.

    There are two options:

    1. You generate all information automatically so that the header and content are always in sync. This is not recommended as you don’t have any flexibility where it comes to how you want to display your information
    2. Add the header row manually as well. This way you can display whatever you want and you can use a simple block of html to achieve that.

    As a side-note I would also recommend using th elements instead of td elements for the header row.

    So you would replace:

    for($i=0; $i<$ticketloadfield_num; $i++)
    {
    $ticketloadfield = mysql_fetch_field($ticketloadquery);
    echo "<td>{$ticketloadfield->name}</td>";
    }
    

    with:

    ?>
    <th>Owner</th>
    <th>In Progress</th>
    <th>Pending Customer</th>
    <th>Customer Replied</th>
    <th>Suggested Resolution</th>
    <th>Total Workable</th>
    <?php
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple MySQL query that selects all columns from the table based
I have a simple MySQL query that looks something like this SELECT * FROM
I have a simple stats query in mysql. I had it working using php
I have a simple query in php on oracle: $query='select u.username,u.lastname,u.firstname,c.event,c.reason from users u,
I have a simple page view tracker that uses a combination of PHP and
I have MySQL table that doesn't have AUTO_INCREMENT field. In PHP I run this
I have a simple admin I'm creating for a client using PHP and Mysql.
I have a simple query like: select count(*) from table Can I speed up
I have a simple query that finds cities that are within a certain distance
I have a simple query to show a given users photos: SELECT pid FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.