salve, avreste qualche consiglio per velocizzare l'accesso di dati da due tabelle una con poche righe e l' altra con circa 200 righe. Il codice è questo, il problema è che per caricare la lista in una pagina ci mette 5 secondi anche di piu, non mi sembra normale visto che alla fine sono solo circa 210 righe in totale.
Codice PHP:
<?php
include('config.php');
/* CONTO QUANTE RIGHE STAMPARE */
$sqlcatC = "SELECT id FROM categorie ORDER BY id DESC LIMIT 0, 1;";
$requestcatC = mysqli_query($con, $sqlcatC);
$rowcatC = mysqli_fetch_row($requestcatC);
$numcat = $rowcatC[0];
$i = 1;
while ($i <= $numcat) {
/* STAMPO UNA CATEGORIA */
$sqlcat = "SELECT categoria FROM categorie WHERE id = '$i';";
$requestcat = mysqli_query($con, $sqlcat);
$rowcat = mysqli_fetch_row($requestcat);
$categoria = $rowcat[0];
echo('<option class=opt-categoria>'.$categoria.'</option>');
/* CONTO QUANTE SOTTOCATEGORIE PESENTI IN CATEGORIA APPENA STAMPATA*/
$sqlsotC = "SELECT id FROM sottocategorie ORDER BY id DESC LIMIT 0, 1;";
$requestsotC = mysqli_query($con, $sqlsotC);
$rowsotC = mysqli_fetch_row($requestsotC);
$numsot = $rowsotC[0];
$y = 1;
while ($y <= $numsot) {
/* ISOLO LE SOTTOCATEGORIE DI ALTRE CATEGORIE E STAMPO SOLO SOOTTOCATEGORIE DELLA CATEGORIA APPENA STAMPATA */
$sqlsot = "SELECT sottocategoria FROM sottocategorie WHERE id = $y AND idcategoria = $i;";
$requestsot = mysqli_query($con, $sqlsot);
$rowsot = mysqli_fetch_row($requestsot);
$sottocategoria = $rowsot[0];
if($sottocategoria != NULL){
echo('<option>'.$sottocategoria.'</option>');$y++;}
else{$y++;}
}
$i++;
}
?>