Ciao ragazzi. Ho un problema con il seguente codice.
In pratica questo mi genera una tabella con due colonne con tutti i nomi delle provincie e fin qui tutto bene perchè l'elenco è perfetto e anche l'incolonnamento.
Il problema riguarda il link alla pagina della provincie.
In pratica mi fa l'elenco delle provincie ma mi genera per tutte lo stesso link fermo ad Alessandria! ($city_url)
Non riesco a capire dov'è l'errore. Se qualcuno può aiutarmi mi farebbe un gran piacere

[PHP]
<table width="170" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffCC">
<tr>
<td width="989" valign="top"><?php

// Show city list

if($location_sort)
{
$sort1 = "ORDER BY countryname";
$sort2 = "ORDER BY cityname";
}
else
{
$sort1 = "ORDER BY c.pos";
$sort2 = "ORDER BY ct.pos";
}

if ($show_region_adcount || $show_city_adcount)
{
// First get ads per city and country
$country_adcounts = array();
$city_adcounts = array();
$sql = "SELECT ct.cityid, c.countryid, COUNT(*) as adcnt
FROM $t_ads a
INNER JOIN $t_cities ct ON ct.cityid = a.cityid AND ($visibility_condn)
INNER JOIN $t_countries c ON ct.countryid = c.countryid
WHERE ct.enabled = '1' AND c.enabled = '1'
GROUP BY ct.cityid";

$res = mysql_query($sql) or die(mysql_error().$sql);

while($row=mysql_fetch_array($res))
{
$country_adcounts[$row['countryid']] += $row['adcnt'];
$city_adcounts[$row['cityid']] += $row['adcnt'];
}
}

$sql = "SELECT * FROM $t_countries c INNER JOIN $t_cities ct ON c.countryid = ct.countryid AND ct.enabled = '1' WHERE c.enabled = '1' GROUP BY c.countryid $sort1";
$resc = mysql_query($sql);

$country_count = mysql_num_rows($resc);
//$split_at = ($country_count%3?((int)($country_count/3))+2$country_count/3)+1);
$percol = floor($country_count/$location_cols);
$percolA = array();
for($i=1;$i<=$location_cols;$i++) $percolA[$i]=$percol+($i<=$country_count%$location_cols?1:0);

$i = 0; $j = 0;
$col = 1;
while($country = mysql_fetch_array($resc))
{
if($sef_urls) $country_url = "{$vbasedir}-$country[countryid]_" . RemoveBadURLChars($country['countryname']) . "/";
else $country_url = "?cityid=-$country[countryid]&lang=$xlang";

?>


<div><?php echo $country['countryname']; ?> <?php if($show_region_adcount) echo "(".(0+$country_adcounts[$country['countryid']]).")"; ?></div>




<?php
if($country['countryid'] == $xcountryid || !$expand_current_region_only)
{

$sql = "SELECT * FROM $t_cities ct WHERE countryid = $country[countryid] AND enabled = '1' $sort2";
$resct = mysql_query($sql);

while($city=mysql_fetch_array($resct))
{
if($sef_urls) $city_url = "{$vbasedir}$city[cityid]_" . RemoveBadURLChars($city['cityname']) . "/";
else $city_url = "?cityid=$city[cityid]&lang=$xlang";

$num_record = mysql_num_rows($resct);
$colonne = 2;
$tot_righe = $num_record/$colonne;
$i_x = 0;
$x_x = 0;
$k_x = 0;
$cell_width = floor(100/$colonne);

echo
'<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffCC">
<tr>';
while($city = mysql_fetch_array($resct))
{
$i_x++;
$k_x++;
$x_x++;
echo "<td width=\"".$cell_width."%\"><a href=\"".$city_url."\" class=\"citylist_city\">".$city['cityname']."";
if($show_city_adcount)
$a = "(0+".$city_accounts[$city['cityid']].")";
echo "".$a."</a>
</td>";

if($i_x == $colonne)
{
echo'</tr>';
if($i_x == $colonne && (($x_x/$colonne) != $tot_righe))
{
echo'<tr>';
}
$i_x = 0;
}
}
if($colonne <= $x_x)
{
if(($k_x%$colonne) != 0)
{
$indice = $k_x;
while (($indice%$colonne) != 0 )
{
echo'<td></td>';
$indice++;
}
if(($indice%$colonne) == 0 )
{
echo'</tr>';
}
}
}
else{
echo '</tr>';
}
echo '</table>';
?>



<?php

}
}

?>


<?php



}

?></td>
</tr>
</table>
[PHP]