dovrei aver risolto così:
Codice PHP:
function selectSection() {
global $config;
try {
$result = $config->getPdo()->query("SELECT * FROM sezioni");
return $result;
} catch (Exception $e) {
die($e->getMessage());
}
}
function selectCategory($sec) {
global $config;
try {
$result = $config->getPdo()->query("SELECT * FROM categorie WHERE sezione_FK=" . $sec);
return $result;
} catch (Exception $e) {
die($e->getMessage());
}
}
Codice PHP:
<ul>
<?php
foreach (selectSection () as $liSection) {
echo '[*][url="index.php?action=update_sec&id=' . $liSection['sezione_id'] . '&a=' . $liSection['sezione_nome'] . '"]' . $liSection['sezione_nome'] . '[/url]';
foreach (selectCategory($liSection['sezione_id']) as $listCat) {
echo '<ul>';
echo '[*][url="index.php?action=update_cat&cid=' . $listCat['categoria_id'] . '&c=' . $listCat['categoria_nome'] . '"]' . $listCat['categoria_nome'] . '[/url]';
echo '[/list]';
}
echo '';
}
?>[/list]
faccio due query.
nella seconda passo l'id trovato nella prima.