<?php
mysql_connect("localhost", "xxx", "xxx") or die(mysql_error());
mysql_select_db("asterisk_realtime") or die(mysql_error());
//Selects agents ready and talking - filters logged out and not ready
$query = "SELECT agents.name,agents.agent_code,agent_sessions.status FROM agents,agent_sessions
WHERE agents.agentid = agent_sessions.agentid AND (agent_sessions.status='ready' OR agent_sessions.status='talking')
ORDER BY agents.name";
$result = mysql_query($query);
//if (!$result) {
// $message = 'Invalid Query: ' . mysql_error() . "\n";
// $message .= 'Whole query: ' . $query;
// die($message);
//}
echo "<table border='5'>";
echo "<tr> <th>Name</th> <th>Calling Code</th> <th>Status</th> </tr>";
while ($row = mysql_fetch_assoc($result)) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['agent_code'];
echo "</td><td>";
echo $row['status'];
echo "</td></tr>";
}
mysql_free_result($result);
$foo = $_POST['foo'];
?>
|