you did not include the ORDER BY...
in the string causing syntax error,
$queryPro = "select...AND SubMenuOf=".$rowCat["PageNumber"] . " Order By SortOrder ASC";
As a sidenote, the query is vulnerable with SQL Injection
if the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By using PreparedStatements
you can get rid of using single quotes around values.