Intenta lo siguiente:
Solo tenga en cuenta que he arreglado sql para usted.
<?php
$sql = "SELECT itemname, SUM(quantity) AS quantity from tblorders GROUP BY itemname";
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0) {
foreach($results as $result) { ?>
<tr>
<td> <?php echo htmlentities($cnt);?></td>
<td><?php echo htmlentities($result->itemname);?></td>
<td><?php echo htmlentities ($result->quantity);?></td>
</tr>
<?php
$cnt++;
}
}
?>