How do I show the result of an SQLSRV query in PHP?

Asked

Viewed 1,261 times

3

I need to do a calculation via sqlsrv, add a column of values.

This is the code I tried to make:

$qryAC = "SELECT SUM(VLRECEITACONT) AS receitaConta
          FROM [RDO].[dbo].[ANALISE_CRITICA]
          WHERE CC='$partCC[$i]' ";

$stmtAC = sqlsrv_query( $conn, $qryAC );
echo $stmtAC;

How do I display the result of this query?

1 answer

3


After transforming the text contained in $qryAC in a consultation it is necessary to pick up your return with sqlsrv_fetch_array() or similar.

$stmtAC = sqlsrv_query($conn, $qryAC);

while( $item = sqlsrv_fetch_array($stmtAC, SQLSRV_FETCH_ASSOC)){
      echo $item['receitaConta']."<br>";
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.