I try to count the event-code. What are the changes I need to do to achieve it?
Please help me with that.
My code:
$serverName = "IE3PDT1QJ67P4";
$connectionInfo = array( "Database"=>"TestEventsDB");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}
else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT count(EventCode) FROM AlarmPointEvent where AlarmPoint=24001";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
echo $row['EventCode']."<br>";
}
sqlsrv_free_stmt( $stmt);
?>
count(EventCode) AS EventCodeCountand then you can use$row['EventCodeCount']