Customer Information
';
print db2_conn_errormsg ();
}
$sql = "select * from phpsample.custmast";
print '' . $sql . '
';
$stmt = db2_prepare($connection, $sql); //returns false if connection failed
if (!$stmt) {
die ("error with statement");
}
$result = db2_execute($stmt); //returns false if execution failed
if (!$result){
print db2_stmt_error();
print db2_stmt_errormsg();
}
print '';
print '| Cust Number | | Customer Name | Address | ' .
'YTD Sales | |
';
$total = 0;
while ($row = db2_fetch_assoc($stmt)){
printf("| %06d | %s | %s | %s | %.2f |
", $row['CCUSNO'],
$row['CCMP'],$row['CCSNAM'],$row['CADDR1'],$row['CYTDSL']);
$total = $total + $row['CYTDSL'];
}
//print total
printf ("| Total YTD Sales | %.2f |
", $total);
print '
';
?>