I am new to php and I messed it up my code little bit. I would appreciate any help.
$sqltest="SELECT MaId,Amount FROM table1";
$stmttest = sqlsrv_query( $conn, $sqltest);
if( $stmttest === false) {
die( print_r( sqlsrv_errors(), true) );
}
while($test = sqlsrv_fetch_array( $stmttest, SQLSRV_FETCH_ASSOC)){ //fetch array
$combined[] = array($test['MaId']=>$test['Amount']); //pass the first column values as array keys
}
$loop=0;
foreach ($combined as $key => $value) {
foreach ($value as $msid => $msamount) {
while($msid!==25) {
$loop += $msamount;
}
}
}
I am trying to sum the all the amounts where the id is not equal to 25, but I'm getting stuck in an infinite loop. Can you explain what's going wrong?