Use this Query
SELECT GROUP_CONCAT(Bookno SEPARATOR ' ') as booknum FROM ORDERS BY Catno;
Result will be
while ($row = mysql_fetch_assoc($result)) {
$catno=$row['Catno']
$arrayResult[$catno]=explode(" ", $row['booknum']);
}
that $arrarResult
gives data like you want