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

3

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

Here is the code I tried to do:

$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?

    
asked by anonymous 16.10.2014 / 19:59

1 answer

3

After transforming the text contained in $qryAC into a query it is necessary to get its 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>";
}
    
16.10.2014 / 20:10