$sql = <<<SQL
SELECT * FROM `orders` WHERE `orderid` = '$view' AND `isline` = 'no'
SQL;
if(!$result = $db->query($sql)){ die('There was an error running the query [' .$db->error . ']');}
$totalqty=0; // add this
while($row = $result->fetch_assoc()){
echo '<h2>Order Id : '.$row['orderid'].'</h2>';
echo '<p><strong>Customer Order Number : '.$row['customerordernumber'].'</strong></p>';
echo '<p><strong>Order Date :</strong> '.date("d/m/Y H:i:s", strtotime($row["orderdatetime"])).'</p>';
echo '<p><strong>Order Notes :</strong> '.$row['ordernotes'].'</p>';
echo '<p><strong>Label Type :</strong> '.$row['labeltype'].'</p>';
echo '<p><strong>Trolley Type :</strong> '.$row['trolleytype'].'</p>';
echo '<p><strong>Deliver By :</strong> '.$row['deliverby'].'</p>';
echo '<p><strong>Ordered Items : </strong></p>';
$totalqty+=intval($row['QTY??']); //your field value must be changed add this
}
Just add one counter variable as above :)