$query = "SELECT \n\t\t\tevents.nodeid, \n\t\t\tevents.eventtime, \n\t\t\tevents.ipaddr, \n\t\t\tevents.serviceid, \n\t\t\tevents.eventseverity, \n\t\t\tevents.eventlogmsg, \n\t\t\tnode.nodesysoid\n\t\t\tFROM \n\t\t\tpublic.events, \n\t\t\tpublic.node\n\t\t\tWHERE \n\t\t\tevents.nodeid = node.nodeid AND\n\t\t\tevents.ipaddr = {$newipaddress}\n\t\t\tORDER BY\n\t\t\tevents.eventtime DESC;";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$total_alarm_number = pg_num_rows($result);
echo "<thead>";
echo "<tr class=headings>";
echo "<th align=left class=table-filterable table-sortable:default><b>Device Category</b></th>";
echo "<th align=left class=table-filterable table-sortable:default><b>Alarm Severity</b></th>";
echo "<th align=left class=table-filterable table-sortable:default><b>Service</b></th>";
echo "<th align=left class=table-sortable:alphanumeric><b>Time</b></th>";
echo "<th align=left class=table-sortable:text><b>Log Message</b></th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($row = pg_fetch_object($result)) {
    echo "\t<tr class=even pointer>\n";
    $deviceCategory = deviceCat($row->nodesysoid);
    echo "\t\t<td align=left>{$deviceCategory}</td>";
    $seve = visulize_severe($row->eventseverity);
    echo "\t\t<td align=left>{$seve}</td>";
    $service = service_id($row->serviceid);
    echo "\t\t<td align=left>{$service}</td>";
    echo "\t\t<td align=left>{$row->eventtime}</td>";
    echo "\t\t<td align=left>{$row->eventlogmsg}</td>";
    echo "\t</tr>\n";
}
pg_free_result($result);
pg_close($dbconn);
?>
		</tr></table>

echo "<th align=left class=table-sortable:text><b>Log Message</b><img src=images/sorticon.png width=30 height=20></th>";
echo "<th align=right><b>Acknowledge</b></th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($row = pg_fetch_object($result)) {
    echo "\t<tr class=even pointer>\n";
    echo "\t\t<td align=left>{$row->alarmid}</td>";
    echo "\t\t<td align=left>{$row->ip}</td>";
    //$deviceCategory = deviceCat($row->nodesysoid);
    //echo "\t\t<td align=left>$deviceCategory</td>";
    //	echo "\t\t<td align=left>$row->deviceid</td>";
    $d = getDeviceCate($row->logs);
    echo "\t\t<td align=left>{$d}</td>";
    //$seve=visulize_severe($row->severity);
    $v = visulize_severe($row->severity);
    echo "\t\t<td align=left>{$v}</td>";
    //	$service = service_id($row->serviceid);
    echo "\t\t<td align=left>{$row->mac}</td>";
    //$alarmtype = alarm_type($row->alarmtype);
    $alarmTime = displayTime($row->time);
    echo "\t\t<td align=left>{$alarmTime}</td>";
    echo "\t\t<td align=left>{$row->logs}</td>";
    //	echo "\t\t<td align=center><a href=php_scripts/alarm_acknowledge_dialog.php?alarmid=$row->alarmid target=_blank ><img src=images/2c_go.png width=25 height=25></a></td>";
    echo "\t\t<td align=center><a href=php_scripts/curl_acknowlegeAlarm.php?alarmid={$row->alarmid} target=_blank ><img src=images/2c_go.png width=25 height=25></a></td>";
    echo "\t</tr>\n";
}
pg_free_result($result);
pg_close($dbconn);
function displayTime($t)
{