alternate now color

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ablonashid
Forum Newbie
Posts: 2
Joined: Thu Jan 24, 2008 10:40 pm

alternate now color

Post by ablonashid »

I want change row color on my mysql table field "status".
example:table alarm table.if any critical alarm come row color change to red.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: alternate now color

Post by s.dot »

What have you tried?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
ablonashid
Forum Newbie
Posts: 2
Joined: Thu Jan 24, 2008 10:40 pm

Re: alternate now color

Post by ablonashid »

<? session_start(); ?>
<html>
<head>
<title>NMS -- dbo.lst_all_current_alarms</title>
<meta name="generator" content="text/html">
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body>
<table class="bd" width="100%"><tr><td class="hr"><h2>NMS ADMIN</h2></td></tr></table>
<table width="100%">
<tr>

<td width="10%" valign="top">
<li><a href="index.php">Index</a>
</td>
<td width="5%">
</td>
<td bgcolor="#e0e0e0">
</td>
<td width="5%">
</td>
<td width="80%" valign="top">
<?
if (!login()) exit;
?>
<div style="float: right"><a href="dbo_lst_all_current_alarms.php?a=logout">[ Logout ]</a></div>
<br>
<?
$conn = connect();
$showrecs = 20;
$pagerange = 10;

$a = @$_GET["a"];
$recid = @$_GET["recid"];
if (isset($_GET["order"])) $order = @$_GET["order"];
if (isset($_GET["type"])) $ordtype = @$_GET["type"];

if (isset($_POST["filter"])) $filter = @$_POST["filter"];
if (isset($_POST["filter_field"])) $filterfield = @$_POST["filter_field"];
$wholeonly = false;
if (isset($_POST["wholeonly"])) $wholeonly = @$_POST["wholeonly"];

if (!isset($order) && isset($_SESSION["order"])) $order = $_SESSION["order"];
if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = $_SESSION["type"];
if (!isset($filter) && isset($_SESSION["filter"])) $filter = $_SESSION["filter"];
if (!isset($filterfield) && isset($_SESSION["filter_field"])) $filterfield = $_SESSION["filter_field"];

$page = @$_GET["page"];
if (!isset($page)) $page = 1;

$sql = @$_POST["sql"];

switch ($sql) {
case "insert":
sql_insert();
break;
case "update":
sql_update();
break;
case "delete":
sql_delete();
break;
}

switch ($a) {
case "add":
addrec();
break;
case "view":
viewrec($recid);
break;
case "edit":
editrec($recid);
break;
case "del":
deleterec($recid);
break;
default:
select();
break;
}

if (isset($order)) $_SESSION["order"] = $order;
if (isset($ordtype)) $_SESSION["type"] = $ordtype;
if (isset($filter)) $_SESSION["filter"] = $filter;
if (isset($filterfield)) $_SESSION["filter_field"] = $filterfield;
if (isset($wholeonly)) $_SESSION["wholeonly"] = $wholeonly;

mssql_close($conn);
?>
</td></tr></table>
<table class="bd" width="100%"><tr><td class="hr"></td></tr></table>
</body>
</html>

<? function select()
{
global $a;
global $showrecs;
global $page;
global $filter;
global $filterfield;
global $wholeonly;
global $order;
global $ordtype;


if ($a == "reset") {
$filter = "";
$filterfield = "";
$wholeonly = "";
$order = "";
$ordtype = "";
}

$checkstr = "";
if ($wholeonly) $checkstr = " checked";
if ($ordtype == "asc") { $ordtypestr = "desc"; } else { $ordtypestr = "asc"; }
$res = sql_select();
$count = sql_getrecordcount();
if ($count % $showrecs != 0) {
$pagecount = intval($count / $showrecs) + 1;
}
else {
$pagecount = intval($count / $showrecs);
}
$startrec = $showrecs * ($page - 1);
if ($startrec < $count) {mssql_data_seek($res, $startrec);}
$reccount = min($showrecs * $page, $count);
$fields = array(
"bsc" => "bsc",
"site_name" => "site_name",
"EventName" => "EventName",
"EventAlias" => "EventAlias",
"Levelofalarm" => "Levelofalarm",
"Occtime" => "Occtime",
"Clstime" => "Clstime",
"Alarmdate" => "Alarmdate",
"Send" => "Send",
"Status" => "Status",
"Duration" => "Duration",
"site_id" => "site_id");
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr><td>Table: dbo.lst_all_current_alarms</td></tr>
<tr><td>Records shown <? echo $startrec + 1 ?> - <? echo $reccount ?> of <? echo $count ?></td></tr>
</table>
<hr size="1" noshade>
<form action="dbo_lst_all_current_alarms.php" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><b>Custom Filter</b>&nbsp;</td>
<td><input type="text" name="filter" value="<? echo $filter ?>"></td>
<td><select name="filter_field">
<option value="">All Fields</option>
<?
reset($fields);
foreach($fields as $val => $caption) {
if ($val == $filterfield) {$selstr = " selected"; } else {$selstr = ""; }
?>
<option value="<? echo $val ?>"<? echo $selstr ?>><? echo htmlspecialchars($caption) ?></option>
<? } ?>
</select></td>
<td><input type="checkbox" name="wholeonly"<? echo $checkstr ?>>Whole words only</td>
</td></tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="action" value="Apply Filter"></td>
<td><a href="dbo_lst_all_current_alarms.php?a=reset">Reset Filter</a></td>
</tr>
</table>
</form>
<hr size="1" noshade>
<? showpagenav($page, $pagecount); ?>
<br>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="100%">
<tr>
<?
reset($fields);
foreach($fields as $val => $caption) {
?>
<td class="hr"><a class="hr" href="dbo_lst_all_current_alarms.php?order=<? echo $val ?>&type=<? echo $ordtypestr ?>"><? echo htmlspecialchars($caption) ?></a></td>
<? } ?>
<td class="hr">&nbsp;</td>
<td class="hr">&nbsp;</td>
<td class="hr">&nbsp;</td>
</tr>
<?
for ($i = $startrec; $i < $reccount; $i++)
{
$row = mssql_fetch_assoc($res);
$style = "dr";
if ($i % 2 != 0) {
$style = "sr";
}
?>
<tr>
<?
reset($fields);
foreach($fields as $val => $caption) {
?>
<td class="<? echo $style ?>"><? echo htmlspecialchars($row[$val]) ?></td>
<? } ?>
<td class="<? echo $style ?>"><a href="dbo_lst_all_current_alarms.php?a=view&recid=<? echo $i ?>">View</a></td>
<td class="<? echo $style ?>"><a href="dbo_lst_all_current_alarms.php?a=edit&recid=<? echo $i ?>">Edit</a></td>
<td class="<? echo $style ?>"><a href="dbo_lst_all_current_alarms.php?a=del&recid=<? echo $i ?>">Delete</a></td>
</tr>
<?
}
mssql_free_result($res);
?>
</table>
<br>
<? showpagenav($page, $pagecount); ?>
<? } ?>

<? function login()
{
global $_POST;
global $_SESSION;

global $_GET;
if (isset($_GET["a"]) && ($_GET["a"] == 'logout')) $_SESSION["logged_in"] = false;
if (!isset($_SESSION["logged_in"])) $_SESSION["logged_in"] = false;
if (!$_SESSION["logged_in"]) {
$login = "";
$password = "";
if (isset($_POST["login"])) $login = @$_POST["login"];
if (isset($_POST["password"])) $password = @$_POST["password"];

if (($login != "") && ($password != "")) {
if (($login == "omcr") && ($password == "omc-r")) {
$_SESSION["logged_in"] = true;
}
else {
?>
<p><b><font color="-1">Sorry, the login/password combination you've entered is invalid</font></b></p>
<? } } }if (isset($_SESSION["logged_in"]) && (!$_SESSION["logged_in"])) { ?>
<form action="dbo_lst_all_current_alarms.php" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td>Login</td>
<td><input type="text" name="login" value="<? echo $login ?>"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" value="<? echo $password ?>"></td>
</tr>
<tr>
<td><input type="submit" name="action" value="Login"></td>
</tr>
</table>
</form>
<?
}
if (!isset($_SESSION["logged_in"])) $_SESSION["logged_in"] = false;
return $_SESSION["logged_in"];
} ?>

<? function login_add()
{
global $_POST;
global $_SESSION;
if (!isset($_SESSION["logged_add"])) $_SESSION["logged_add"] = false;
if (!$_SESSION["logged_add"]) {
$login = "";
$password = "";
if (isset($_POST["login_add"])) $login = @$_POST["login_add"];
if (isset($_POST["password_add"])) $password = @$_POST["password_add"];

if (($login != "") && ($password != "")) {
if (($login == "haroon") && ($password == "farucroft")) {
$_SESSION["logged_add"] = true;
}
else {
?>
<p><b><font color="-1">Sorry, the login/password combination you've entered is invalid</font></b></p>
<? } } }if (isset($_SESSION["logged_add"]) && (!$_SESSION["logged_add"])) { ?>
<form action="dbo_lst_all_current_alarms.php?a=add" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td>Login</td>
<td><input type="text" name="login_add" value="<? echo $login ?>"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password_add" value="<? echo $password ?>"></td>
</tr>
<tr>
<td><input type="submit" name="action" value="Login"></td>
</tr>
</table>
</form>
<?
}
if (!isset($_SESSION["logged_add"])) $_SESSION["logged_add"] = false;
return $_SESSION["logged_add"];
} ?>

<? function showrow($row)
{
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><? echo htmlspecialchars("bsc")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["bsc"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("site_name")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["site_name"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("EventName")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["EventName"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("EventAlias")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["EventAlias"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Levelofalarm")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Levelofalarm"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Occtime")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Occtime"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Clstime")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Clstime"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Alarmdate")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Alarmdate"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Send")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Send"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Status")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Status"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Duration")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Duration"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("site_id")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["site_id"]) ?></td>
</tr>
</table>
<? } ?>

<? function showroweditor($row)
{
global $conn;
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><? echo htmlspecialchars("bsc")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="bsc" maxlength="4" value="<? echo str_replace('"', '"', trim($row["bsc"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("site_name")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="site_name" maxlength="50" value="<? echo str_replace('"', '"', trim($row["site_name"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("EventName")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="EventName" maxlength="50" value="<? echo str_replace('"', '"', trim($row["EventName"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("EventAlias")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="EventAlias" maxlength="14" value="<? echo str_replace('"', '"', trim($row["EventAlias"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Levelofalarm")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Levelofalarm" maxlength="15" value="<? echo str_replace('"', '"', trim($row["Levelofalarm"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Occtime")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Occtime" value="<? echo str_replace('"', '"', trim($row["Occtime"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Clstime")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Clstime" value="<? echo str_replace('"', '"', trim($row["Clstime"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Alarmdate")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Alarmdate" value="<? echo str_replace('"', '"', trim($row["Alarmdate"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Send")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Send" maxlength="3" value="<? echo str_replace('"', '"', trim($row["Send"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Status")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Status" maxlength="15" value="<? echo str_replace('"', '"', trim($row["Status"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Duration")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Duration" maxlength="10" value="<? echo str_replace('"', '"', trim($row["Duration"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("site_id")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="site_id" value="<? echo str_replace('"', '"', trim($row["site_id"])) ?>"></td>
</tr>
</table>
<? } ?>

<? function showpagenav($page, $pagecount)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="dbo_lst_all_current_alarms.php?a=add">Add Record</a>&nbsp;</td>
<? if ($page > 1) { ?>
<td><a href="dbo_lst_all_current_alarms.php?page=<? echo $page - 1 ?>"><<&nbsp;Prev</a>&nbsp;</td>
<? } ?>
<?
global $pagerange;

if ($pagecount > 1) {

if ($pagecount % $pagerange != 0) {
$rangecount = intval($pagecount / $pagerange) + 1;
}
else {
$rangecount = intval($pagecount / $pagerange);
}
for ($i = 1; $i < $rangecount + 1; $i++) {
$startpage = (($i - 1) * $pagerange) + 1;
$count = min($i * $pagerange, $pagecount);

if ((($page >= $startpage) && ($page <= ($i * $pagerange)))) {
for ($j = $startpage; $j < $count + 1; $j++) {
if ($j == $page) {
?>
<td><b><? echo $j ?></b></td>
<? } else { ?>
<td><a href="dbo_lst_all_current_alarms.php?page=<? echo $j ?>"><? echo $j ?></a></td>
<? } } } else { ?>
<td><a href="dbo_lst_all_current_alarms.php?page=<? echo $startpage ?>"><? echo $startpage ."..." .$count ?></a></td>
<? } } } ?>
<? if ($page < $pagecount) { ?>
<td>&nbsp;<a href="dbo_lst_all_current_alarms.php?page=<? echo $page + 1 ?>">Next&nbsp;>></a>&nbsp;</td>
<? } ?>
</tr>
</table>
<? } ?>

<? function showrecnav($a, $recid, $count)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="dbo_lst_all_current_alarms.php">Index Page</a></td>
<? if ($recid > 0) { ?>
<td><a href="dbo_lst_all_current_alarms.php?a=<? echo $a ?>&recid=<? echo $recid - 1 ?>">Prior Record</a></td>
<? } if ($recid < $count) { ?>
<td><a href="dbo_lst_all_current_alarms.php?a=<? echo $a ?>&recid=<? echo $recid + 1 ?>">Next Record</a></td>
<? } ?>
</tr>
</table>
<hr size="1" noshade>
<? } ?>

<? function addrec()
{
if (!login_add()) exit;
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="dbo_lst_all_current_alarms.php">Index Page</a></td>
</tr>
</table>
<hr size="1" noshade>
<form action="dbo_lst_all_current_alarms.php" method="post">
<p><input type="hidden" name="sql" value="insert"></p>
<?
$row = array(
"bsc" => "",
"site_name" => "",
"EventName" => "",
"EventAlias" => "",
"Levelofalarm" => "",
"Occtime" => "",
"Clstime" => "",
"Alarmdate" => "",
"Send" => "",
"Status" => "",
"Duration" => "",
"site_id" => "");
showroweditor($row)
?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<? } ?>

<? function viewrec($recid)
{
$res = sql_select();
$count = sql_getrecordcount();
mssql_data_seek($res, $recid);
$row = mssql_fetch_assoc($res);
showrecnav("view", $recid, $count);
?>
<br>
<? showrow($row) ?>
<br>
<hr size="1" noshade>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="dbo_lst_all_current_alarms.php?a=add">Add Record</a></td>
<td><a href="dbo_lst_all_current_alarms.php?a=edit&recid=<? echo $recid ?>">Edit Record</a></td>
<td><a href="dbo_lst_all_current_alarms.php?a=del&recid=<? echo $recid ?>">Delete Record</a></td>
</tr>
</table>
<?
mssql_free_result($res);
} ?>



<? function editrec($recid)
{
$res = sql_select();
$count = sql_getrecordcount();
mssql_data_seek($res, $recid);
$row = mssql_fetch_assoc($res);
showrecnav("edit", $recid, $count);
?>
<br>
<form action="dbo_lst_all_current_alarms.php" method="post">
<input type="hidden" name="sql" value="update">
<input type="hidden" name="xbsc" value="<? echo $row["bsc"] ?>">
<input type="hidden" name="xsite_name" value="<? echo $row["site_name"] ?>">
<input type="hidden" name="xEventName" value="<? echo $row["EventName"] ?>">
<input type="hidden" name="xEventAlias" value="<? echo $row["EventAlias"] ?>">
<input type="hidden" name="xLevelofalarm" value="<? echo $row["Levelofalarm"] ?>">
<input type="hidden" name="xOcctime" value="<? echo $row["Occtime"] ?>">
<input type="hidden" name="xClstime" value="<? echo $row["Clstime"] ?>">
<input type="hidden" name="xAlarmdate" value="<? echo $row["Alarmdate"] ?>">
<input type="hidden" name="xSend" value="<? echo $row["Send"] ?>">
<input type="hidden" name="xStatus" value="<? echo $row["Status"] ?>">
<input type="hidden" name="xDuration" value="<? echo $row["Duration"] ?>">
<input type="hidden" name="xsite_id" value="<? echo $row["site_id"] ?>">
<? showroweditor($row) ?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<?
mssql_free_result($res);
} ?>

<? function deleterec($recid)
{
$res = sql_select();
$count = sql_getrecordcount();
mssql_data_seek($res, $recid);
$row = mssql_fetch_assoc($res);
showrecnav("del", $recid, $count);
?>
<br>
<form action="dbo_lst_all_current_alarms.php" method="post">
<input type="hidden" name="sql" value="delete">
<input type="hidden" name="xbsc" value="<? echo $row["bsc"] ?>">
<input type="hidden" name="xsite_name" value="<? echo $row["site_name"] ?>">
<input type="hidden" name="xEventName" value="<? echo $row["EventName"] ?>">
<input type="hidden" name="xEventAlias" value="<? echo $row["EventAlias"] ?>">
<input type="hidden" name="xLevelofalarm" value="<? echo $row["Levelofalarm"] ?>">
<input type="hidden" name="xOcctime" value="<? echo $row["Occtime"] ?>">
<input type="hidden" name="xClstime" value="<? echo $row["Clstime"] ?>">
<input type="hidden" name="xAlarmdate" value="<? echo $row["Alarmdate"] ?>">
<input type="hidden" name="xSend" value="<? echo $row["Send"] ?>">
<input type="hidden" name="xStatus" value="<? echo $row["Status"] ?>">
<input type="hidden" name="xDuration" value="<? echo $row["Duration"] ?>">
<input type="hidden" name="xsite_id" value="<? echo $row["site_id"] ?>">
<? showrow($row) ?>
<p><input type="submit" name="action" value="Confirm"></p>
</form>
<?
mssql_free_result($res);
} ?>

<? function connect()
{
$conn = mssql_connect("10.10.40.25", "haroon", "free");
mssql_select_db("NMS");
return $conn;
}

function sqlvalue($val, $quote)
{
if ($quote)
$tmp = sqlstr($val);
else
$tmp = $val;
if ($tmp == "")
$tmp = "NULL";
elseif ($quote)
$tmp = "'".$tmp."'";
return $tmp;
}

function sqlstr($val)
{
return str_replace("'", "''", $val);
}

function sql_select()
{
global $conn;
global $order;
global $ordtype;
global $filter;
global $filterfield;
global $wholeonly;

$filterstr = sqlstr($filter);
if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%";
$sql = "select bsc, site_name, EventName, EventAlias, Levelofalarm, Occtime, Clstime, Alarmdate, [Send], Status, Duration, site_id from dbo.lst_all_current_alarms";
if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') {
$sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
} elseif (isset($filterstr) && $filterstr!='') {
$sql .= " where (bsc like '" .$filterstr ."') or (site_name like '" .$filterstr ."') or (EventName like '" .$filterstr ."') or (EventAlias like '" .$filterstr ."') or (Levelofalarm like '" .$filterstr ."') or (Occtime like '" .$filterstr ."') or (Clstime like '" .$filterstr ."') or (Alarmdate like '" .$filterstr ."') or ([Send] like '" .$filterstr ."') or (Status like '" .$filterstr ."') or (Duration like '" .$filterstr ."') or (site_id like '" .$filterstr ."')";
}
if (isset($order) && $order!='') $sql .= " order by \"" .sqlstr($order) ."\"";
if (isset($ordtype) && $ordtype!='') $sql .= " " .sqlstr($ordtype);
$res = mssql_query($sql, $conn);
return $res;
}

function sql_getrecordcount()
{
global $conn;
global $order;
global $ordtype;
global $filter;
global $filterfield;
global $wholeonly;

$filterstr = sqlstr($filter);
if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%";
$sql = "select count(*) from dbo.lst_all_current_alarms";
if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') {
$sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
} elseif (isset($filterstr) && $filterstr!='') {
$sql .= " where (bsc like '" .$filterstr ."') or (site_name like '" .$filterstr ."') or (EventName like '" .$filterstr ."') or (EventAlias like '" .$filterstr ."') or (Levelofalarm like '" .$filterstr ."') or (Occtime like '" .$filterstr ."') or (Clstime like '" .$filterstr ."') or (Alarmdate like '" .$filterstr ."') or ([Send] like '" .$filterstr ."') or (Status like '" .$filterstr ."') or (Duration like '" .$filterstr ."') or (site_id like '" .$filterstr ."')";
}
$res = mssql_query($sql, $conn);
$row = mssql_fetch_assoc($res);
reset($row);
return current($row);
}

function sql_insert()
{
global $conn;
global $_POST;

$sql = "insert into dbo.lst_all_current_alarms (bsc, site_name, EventName, EventAlias, Levelofalarm, Occtime, Clstime, Alarmdate, [Send], Status, Duration, site_id) values (" .sqlvalue(@$_POST["bsc"], true) .", " .sqlvalue(@$_POST["site_name"], true) .", " .sqlvalue(@$_POST["EventName"], true) .", " .sqlvalue(@$_POST["EventAlias"], true) .", " .sqlvalue(@$_POST["Levelofalarm"], true) .", " .sqlvalue(@$_POST["Occtime"], true) .", " .sqlvalue(@$_POST["Clstime"], true) .", " .sqlvalue(@$_POST["Alarmdate"], true) .", " .sqlvalue(@$_POST["Send"], true) .", " .sqlvalue(@$_POST["Status"], true) .", " .sqlvalue(@$_POST["Duration"], true) .", " .sqlvalue(@$_POST["site_id"], false) .")";
mssql_query($sql, $conn);
}

function sql_update()
{
global $conn;
global $_POST;

$sql = "update dbo.lst_all_current_alarms set bsc=" .sqlvalue(@$_POST["bsc"], true) .", site_name=" .sqlvalue(@$_POST["site_name"], true) .", EventName=" .sqlvalue(@$_POST["EventName"], true) .", EventAlias=" .sqlvalue(@$_POST["EventAlias"], true) .", Levelofalarm=" .sqlvalue(@$_POST["Levelofalarm"], true) .", Occtime=" .sqlvalue(@$_POST["Occtime"], true) .", Clstime=" .sqlvalue(@$_POST["Clstime"], true) .", Alarmdate=" .sqlvalue(@$_POST["Alarmdate"], true) .", [Send]=" .sqlvalue(@$_POST["Send"], true) .", Status=" .sqlvalue(@$_POST["Status"], true) .", Duration=" .sqlvalue(@$_POST["Duration"], true) .", site_id=" .sqlvalue(@$_POST["site_id"], false) ." where " ."(bsc=" .sqlvalue(@$_POST["xbsc"], true) .") and (site_name=" .sqlvalue(@$_POST["xsite_name"], true) .") and (EventName=" .sqlvalue(@$_POST["xEventName"], true) .") and (EventAlias=" .sqlvalue(@$_POST["xEventAlias"], true) .") and (Levelofalarm=" .sqlvalue(@$_POST["xLevelofalarm"], true) .") and (Occtime=" .sqlvalue(@$_POST["xOcctime"], true) .") and (Clstime=" .sqlvalue(@$_POST["xClstime"], true) .") and (Alarmdate=" .sqlvalue(@$_POST["xAlarmdate"], true) .") and ([Send]=" .sqlvalue(@$_POST["xSend"], true) .") and (Status=" .sqlvalue(@$_POST["xStatus"], true) .") and (Duration=" .sqlvalue(@$_POST["xDuration"], true) .") and (site_id=" .sqlvalue(@$_POST["xsite_id"], false) .")";
mssql_query($sql, $conn);
}

function sql_delete()
{
global $conn;
global $_POST;

$sql = "delete from dbo.lst_all_current_alarms where " ."(bsc=" .sqlvalue(@$_POST["xbsc"], true) .") and (site_name=" .sqlvalue(@$_POST["xsite_name"], true) .") and (EventName=" .sqlvalue(@$_POST["xEventName"], true) .") and (EventAlias=" .sqlvalue(@$_POST["xEventAlias"], true) .") and (Levelofalarm=" .sqlvalue(@$_POST["xLevelofalarm"], true) .") and (Occtime=" .sqlvalue(@$_POST["xOcctime"], true) .") and (Clstime=" .sqlvalue(@$_POST["xClstime"], true) .") and (Alarmdate=" .sqlvalue(@$_POST["xAlarmdate"], true) .") and ([Send]=" .sqlvalue(@$_POST["xSend"], true) .") and (Status=" .sqlvalue(@$_POST["xStatus"], true) .") and (Duration=" .sqlvalue(@$_POST["xDuration"], true) .") and (site_id=" .sqlvalue(@$_POST["xsite_id"], false) .")";
mssql_query($sql, $conn);
} ?>

row color change on alarm status.
Post Reply