Groupping tableing data

It took around one hour to think and implement. Here is the think free code. I'll revive it with abstraction


$i=0;
$i_total =0;
/* other continents */
$cities = mysql_results("select distinct countryFileName, co.countryName, continent from
countrycity ci, countries co
where ci.countryCode = co.countryCode and ci.countryCode !='US' and co.continent is not null
order by continent, countryName ");

$ceki = false;
foreach($cities as $city){
if($ceki != $city['continent']){
if($ceki){//daha önce çalışmış
for(;($i%4)!=0;$i++){
$output .= " ";
if(($i % 4) == 3)
$output .= "";
}
$output .= "";
$i=0;
}
$output .= "

{$city['continent']}

";
$ceki = $city['continent'];
}
if(!($i % 4))
$output .= ($i % 8)?"":"";
$output .= "{$city['countryName']}";
if(($i % 4) == 3)
$output .= "";
$i++;
$i_total++;
}

for(;($i%4)!=0;$i++){
$output .= " ";
if(($i % 4) == 3)
$output .= "";
}
$output .= "";

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
                         888                               
888
888
888 888 888d888 .d88888 888 888 .d8888b 88888b.
888 888 888P" d88" 888 888 888 d88P" 888 "88b
888 888 888 888 888 Y88 88P 888 888 888
Y88b 888 888 Y88b 888 Y8bd8P Y88b. 888 888
"Y88888 888 "Y88888 Y88P "Y8888P 888 888


Enter the code depicted in ASCII art style.

Similar

  • New technique to win olimpics -

    New technique to win olimpics

    At the 1968 Olympics, Dick Fosbury took the athletics world by surprise with an unusual high-jump technique.

  • Printing mysql_error -

    Printing mysql_error

    This is a code snipped to print mysql error.
    If there is no error mysql_error returns null, thus if evaluates false and there is no output.

  • multiple ON DUPLICATE KEY UPDATE -

    multiple ON DUPLICATE KEY UPDATE

    Here is an example of how to update multiple columns using values supplied in the INSERT statement. This assumes that column 'a' is the unique key.

  • multiple ON DUPLICATE KEY UPDATE -

    multiple ON DUPLICATE KEY UPDATE

    Here is an example of how to update multiple columns using values supplied in the INSERT statement. This assumes that column 'a' is the unique key.

  • php unlink recursive -

    php unlink recursive

    The shortest recursive delete possible.

    <?php
    /**
    * Delete a file or recursively delete a directory
    *
    * @param string $str Path to file or directory
    */