Alla fin fine il tuo codice dovrebbe assomigliare a questo.
Ovviamente non sono stato in grado di testare quindi potrebbe non funzionare. Comunque l'idea c'è.
Codice PHP:
<?php
include('config.php');
$sqlcatC = "SELECT id,categoria FROM categorie ORDER BY id";
$requestcatC = mysqli_query($con, $sqlcatC);
while (list($i,$categoria) = mysqli_fetch_array($requestcatC)) {
/* STAMPO UNA CATEGORIA */
echo('<option class=opt-categoria>'.$categoria.'</option>');
/* ISOLO LE SOTTOCATEGORIE DI ALTRE CATEGORIE E STAMPO SOLO SOOTTOCATEGORIE DELLA CATEGORIA APPENA STAMPATA */
$sqlsot = "SELECT sottocategoria FROM sottocategorie WHERE idcategoria = $i;";
$requestsot = mysqli_query($con, $sqlsot);
while (list($sottocategoria) = mysqli_fetch_array($requestsot)) {
echo('<option>'.$sottocategoria.'</option>');
}
}
?>