Advertisement:

Author Topic: Popular Cities  (Read 3820 times)

MkRahamath

  • Jr. Member
  • **
  • Posts: 73
Re: Popular Cities
« Reply #15 on: February 08, 2017, 09:18:18 pm »
Its working :) Thank you!

butterfly

  • Jr. Member
  • **
  • Posts: 80
Re: Popular Cities
« Reply #16 on: August 24, 2018, 11:05:23 am »
@Teseo

There is bug in your code.
If there is 2 (or more) cities with the same name in different region, your code return data like link, item count, etc. ONLY to first city ()

Can you fix this?

Code: [Select]
        $popularCities = new DAO();

        $popularCities->dao->select('c.s_name as city_name, cs.i_num_items as items');
        $popularCities->dao->from(DB_TABLE_PREFIX.'t_city_stats cs');
        $popularCities->dao->join(DB_TABLE_PREFIX.'t_city c', 'c.pk_i_id = cs.fk_i_city_id', "INNER");
        $popularCities->dao->where('cs.i_num_items > 0');
        $popularCities->dao->orderBy('cs.i_num_items', 'DESC');
        $popularCities->dao->limit(0, 10);

        $result = $popularCities->dao->get();
        $popular_cities = $result->result();

            View::newInstance()->_exportVariableToView('cities', $popular_cities);

            while(osc_has_cities()) {
                echo osc_city_name() . ' (' . osc_city_items() . ')<br />';
                ?>
                <a href="<?php echo osc_city_url(); ?>" title="<?php echo osc_city_name() ; ?>"><?php echo osc_city_name() ; ?> <em>(<?php echo osc_city_items() ; ?>)</em></a>
                <?php
            
}