<?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[Dividere i dati estratti]]></title><description><![CDATA[<p dir="auto">Ciao ragazzi, avrei la necessità di dividere in due colonne i dati estratti dal database, dato che è uno script che ho trovato in rete è sto cercando di fare pratica mi riuscite ad aiutare??</p>
<p dir="auto">In sostanza penso che bisognerebbe annidare un'altro cilo for all'interno dello script solo che non capisco esattamente come fare...</p>
<p dir="auto">I dati dovrebbero essere divisi da una tabella in modo che la metà vada da una parte e l'altra dall'altra, vi provo a postare il codice</p>
<p dir="auto">[PHP]&lt;?php</p>
<p dir="auto">require_once("initvars.inc.php");<br />
require_once("config.inc.php");</p>
<p dir="auto">?&gt;<br />
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;<br />
&lt;?php</p>
<p dir="auto">// Show city list</p>
<p dir="auto">if($location_sort)<br />
{<br />
$sort1 = "ORDER BY countryname";<br />
$sort2 = "ORDER BY cityname";<br />
}<br />
else<br />
{<br />
$sort1 = "ORDER BY c.pos";<br />
$sort2 = "ORDER BY ct.pos";<br />
}</p>
<p dir="auto">if ($show_region_adcount || $show_city_adcount)<br />
{<br />
// First get ads per city and country<br />
$country_adcounts = array();<br />
$city_adcounts = array();<br />
$sql = "SELECT ct.cityid, c.countryid, COUNT(*) as adcnt<br />
FROM $t_ads a<br />
INNER JOIN $t_cities ct ON ct.cityid = a.cityid AND ($visibility_condn)<br />
INNER JOIN $t_countries c ON ct.countryid = c.countryid<br />
WHERE ct.enabled = '1' AND c.enabled = '1'<br />
GROUP BY ct.cityid";</p>
<pre><code>$res = mysql_query($sql) or die(mysql_error().$sql);

while($row=mysql_fetch_array($res))
{
    $country_adcounts[$row['countryid'&rsqb;&rsqb; += $row['adcnt'];
    $city_adcounts[$row['cityid'&rsqb;&rsqb; += $row['adcnt'];
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">$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";<br />
$resc = mysql_query($sql);</p>
<p dir="auto">$country_count = mysql_num_rows($resc);<br />
//$split_at = ($country_count%3?((int)($country_count/3))+2:($country_count/3)+1);<br />
$percol = floor($country_count/$location_cols);<br />
$percolA = array();<br />
for($i=1;$i&lt;=$location_cols;$i++) $percolA*=$percol+($i&lt;=$country_count%$location_cols?1:0);</p>
<p dir="auto">$i = 0; $j = 0;<br />
$col = 1;<br />
while($country = mysql_fetch_array($resc))<br />
{<br />
/* Begin Version 5.0 <em>/<br />
$country_url = buildURL("main", array((0-$country['countryid']), $country['countryname']));<br />
/</em> End Version 5.0 */<br />
?&gt;</p>
<pre><code>&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'&rsqb;&rsqb;).")"; ?&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);
    
    /* Begin Version 5.0 */
    $citycount = mysql_num_rows($resct);
    /* End Version 5.0 */

    while($city=mysql_fetch_array($resct))
    {        
        /* Begin Version 5.0 */
        if ($shortcut_regions &amp;&amp; $citycount == 1 
                &amp;&amp; $city['cityname'] == $country['countryname']) {
            continue;
        }
        
        $city_url = buildURL("main", array($city['cityid'], $city['cityname']));
        /* End Version 5.0 */

?&gt;

        &lt;a href="&lt;?php echo $city_url; ?&gt;" class="citylist_city"&gt;&lt;?php echo $city['cityname']; echo "$xcountryid"; ?&gt;&lt;/a&gt;&lt;br&gt;
        
&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; } 
</code></pre>
<p dir="auto">}</p>
<p dir="auto">?&gt;</p>
<p dir="auto">&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;[/PHP]</p>
<p dir="auto"><img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/customizations/54a3bffb-5e4a-4eb8-81dc-99b2072e5d05-175.gif?v=5l94qfpgdvn" class="not-responsive emoji emoji-customizations emoji--ciauz" title=":ciauz:" alt=":ciauz:" /><img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/customizations/54a3bffb-5e4a-4eb8-81dc-99b2072e5d05-175.gif?v=5l94qfpgdvn" class="not-responsive emoji emoji-customizations emoji--ciauz" title=":ciauz:" alt=":ciauz:" /></p>
]]></description><link>https://connect.gt/topic/110688/dividere-i-dati-estratti</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 01:01:54 GMT</lastBuildDate><atom:link href="https://connect.gt/topic/110688.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 19 Sep 2009 12:26:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dividere i dati estratti on Thu, 11 Feb 2010 15:31:20 GMT]]></title><description><![CDATA[<p dir="auto">Ciao io ho lo stesso problema con lo stesso script!<br />
Sei riuscito a risolvere?</p>
]]></description><link>https://connect.gt/post/858515</link><guid isPermaLink="true">https://connect.gt/post/858515</guid><dc:creator><![CDATA[danisam]]></dc:creator><pubDate>Thu, 11 Feb 2010 15:31:20 GMT</pubDate></item></channel></rss>