<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Aiuto Php] Spezzare elenco in 2 colonne]]></title><description><![CDATA[<p dir="auto">Ciao ragazzi se qualcuno può aiutami mi farebbe un grandissimo piacere perchè io di PHP purtroppo non ci capisco niente!<br />
Sul mio sito in firma, il codice che segue mi genera la colonna sulla destra con la lista delle regioni (in verde il punto).<br />
Il problema è che voglio passare dalle regioni alle province e così facendo la lista diventa troppo lunga! Io vorrei spezzare questa lista in 2 colonne!<br />
E' possibile secondo voi?<br />
Grazie per l'attenzione!</p>
<pre><code>&lt;b&gt;&lt;span class="Stile1"&gt;Filtra per Regione :&lt;/span&gt;&lt;/b&gt;
&lt;table width="100%"&gt;
  &lt;tr&gt;
    &lt;td valign="top"&gt;&lt;?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&lt;=$location_cols;$i++) $percolA[$i]=$percol+($i&lt;=$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]&amp;lang=$xlang";
?&gt;
 
 &lt;div&gt;&lt;a href="&lt;?php echo $country_url; ?&gt;" class="citylist_country"&gt;&lt;?php echo $country['countryname']; ?&gt; &lt;?php if($show_region_adcount) echo "(".(0+$country_adcounts[$country['countryid']]).")"; ?&gt;&lt;/a&gt;&lt;/div&gt;
 
 &lt;?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]&amp;lang=$xlang";
 ?&gt;
   [COLOR=darkgreen]&lt;a href="&lt;?php echo $city_url; ?&gt;" class="citylist_city"&gt;&lt;?php echo $city['cityname']; ?&gt; &lt;?php if($show_city_adcount) echo "(".(0+$city_adcounts[$city['cityid']]).")"; ?&gt;&lt;/a&gt;&lt;br&gt;[/COLOR]
 
 &lt;?php
  }
 }
 ?&gt;
 
 &lt;?php
 $i++; $j++;
 //if($i%$split_at == 0) echo "&lt;/td&gt;&lt;td valign=\"top\"&gt;";
 if ($j%$percolA[$col]==0 &amp;&amp; $i&lt;$country_count) { echo "&lt;/td&gt;&lt;td valign=\"top\"&gt;"; $col++; $j=0; } 
}
?&gt;
&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/topic/45335/aiuto-php-spezzare-elenco-in-2-colonne</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Dec 2026 10:03:37 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/45335.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 02 Sep 2007 11:41:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Aiuto Php] Spezzare elenco in 2 colonne on Mon, 03 Sep 2007 11:25:23 GMT]]></title><description><![CDATA[<p dir="auto">up</p>
]]></description><link>https://dev.connect.gt/post/591921</link><guid isPermaLink="true">https://dev.connect.gt/post/591921</guid><dc:creator><![CDATA[barattomusicale]]></dc:creator><pubDate>Mon, 03 Sep 2007 11:25:23 GMT</pubDate></item></channel></rss>