<?php
 
$serverName = "CBM2K12\SQLEXPRESS"; 
					$uid = "cbmclient";
					$pwd = "ascbm2k";
$connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd,'ReturnDatesAsStrings'=> true, "CharacterSet" => 'utf-8', "Database"=>"SugarCaneScale" );

/* Connect using SQL Server Authentication. */  
$conn = sqlsrv_connect( $serverName, $connectionInfo);  
if( $conn === false )  
{  
	echo "Unable to connect.</br>";  
	die( print_r( sqlsrv_errors(), true));  
} 

$sql = "SELECT * FROM LoadData ORDER BY DateIn DESC";

$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
    die( print_r( sqlsrv_errors(), true) );
}
$tonsin = 0;
  while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) )
 {
     $tonsin += $row['Tons'];
	 
 }

 //end

?>
<h2>Tons In Total</h2>
<p><?php echo $tonsin; ?></p>
<?
$db = null;
?>
