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?
Even if you manage to make an exception for the
IDcolumn 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:
As a side-note I would also recommend using
thelements instead oftdelements for the header row.So you would replace:
with: