Innanzitutto il codice:

<table width="100%" border="0" bgcolor="#F2F2F2">
<tr>
<td>
<?
if ($ID1=="") {
$ID1="2";
}
if ($ID=="") {
$ID="1";
}
$query = "SELECT ID_areesx,Titolo_areesx FROM areesx WHERE ID_areesx = $ID1";
$result = mysql_query($query, $db);
while ($rows = mysql_fetch_array($result)) {
echo "[img]images/indice3.gif[/img] ".$rows["Titolo_areesx"]."";

$query2 = "SELECT ID,Titolo,Area,Link,Sottoarea FROM sottoaree WHERE ID = $ID";
$result2 = mysql_query($query2, $db);
while ($rows2 = mysql_fetch_array($result2)) {
echo " [img]images/indice3.gif[/img] ".$rows2["Titolo"]."";
}
}
?>
</td>
</tr>
</table>


<?
$query = "SELECT ID,Titolo,Area,Link,Sottoarea,Sottoarea2 FROM sottoaree2 WHERE Sottoarea = $ID";
$result = mysql_query($query, $db);
while ($rows = mysql_fetch_array($result)) {
if ($rows["Sottoarea2"]!="" AND $rows["Link"]=="") {
echo "[img]images/indice2.gif[/img] <font size=2><a href=sottoarea2.php?ID2=".$rows["ID"]."&ID1=".$ID."&ID=".$ID1.">".$rows["Titolo"]."</a></font>

";
}
if ($rows["Link"]!="" AND $rows["Sottoarea2"]=="") {
echo "[img]images/indice2.gif[/img] <font size=2>".$rows["Titolo"]."</font>

";
}
if ($rows["Link"]=="" AND $rows["Sottoarea2"]=="" AND $rows["Sottoarea"]=="")

$query2 = "SELECT ID,Titolo,Descrizione,Testo,Data,Ora,Scadenza,Area ,Link,Sottoarea,Sottoarea2,Sottoarea3 FROM notizie WHERE Area = $ID OR Sottoarea = $ID OR Sottoarea2 = $ID OR Sottoarea3 = $ID";
$result2 = mysql_query($query2, $db);
while ($rows2 = mysql_fetch_array($result2)) {
$link = $rows2["Link"];
$area = $rows2["Area"];
$sottoarea = $rows2["Sottoarea"];
$sottoarea2 = $rows2["Sottoarea2"];
$sottoarea3 = $rows2["Sottoarea3"];
if ($link=="") {
echo "[img]images/indice2.gif[/img] <font size=2><a href=articolo.php?ID=".$rows2["ID"].">".$rows2["Titolo"]."</a></font>

";
}
}
}
?>

Ora, io ho una struttura formata da AREA - SOTTOAREA1 SOTTOAREA2, in SOTTOAREA2 va tutto bene, in SOTTOAREA1 mi fa un macello totale coi titoli.
Io cosa vorrei? Che se nel record è indicata la presenza di una SOTTOAREA2 allora mi crea il link su misura, mentre in altri casi mi crea altri link.
Lo so forse è un pò complesso, ma vediamo se ci capiamo. :master: