我对php相当陌生,所以我正在寻找一些方向。我是查询 sql server,我需要对某些列进行求和。如果我使用有效的数组 1、2、3,但我似乎无法获得impresss_total 的值。
$sql = "SELECT * FROM dash_g_adwords_csv";
$stmt = sqlsrv_query($conn, $sql);
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
//while($row = sqlsrv_fetch_rows($stmt)){
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_BOTH) ) {
//print_r($row);
$impressions_total = array('impressions_total', 'impressions_image', 'impressions_search');
//$impressions_total = array(1, 2, 3);
//$click_total = array('$click_text', '$click_image', '$click_search');
echo
"<tr><td>" . $row['brand'] .
"</td><td>" . $row['period'] .
"</td><td>" . array_sum($impressions_total) .
"</td><td>" . array_sum['$click_total'] .
"</td></tr>";
}
sqlsrv_free_stmt( $stmt);