A
A
Alexander Gorkin2018-02-16 14:15:31
SQL
Alexander Gorkin, 2018-02-16 14:15:31

How to make select tag in alphabetical order?

There is code in the OpenCart engine:

<?php
// *	@copyright	OPENCART.PRO 2011 - 2017.
// *	@forum	http://forum.opencart.pro
// *	@source		See SOURCE.txt for source and other copyright.
// *	@license	GNU General Public License version 3; see LICENSE.txt

class ModelLocalisationZone extends Model {
  public function getZone($zone_id) {
    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE zone_id = '" . (int)$zone_id . "' AND status = '1'  ORDER BY country_id");
      
    return $query->row;
  }

  public function getZonesByCountryId($country_id) {
    $zone_data = $this->cache->get('zone.' . (int)$country_id);

    if (!$zone_data) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' AND status = '1' ORDER BY country_id");

      $zone_data = $query->rows;

      $this->cache->set('zone.' . (int)$country_id, $zone_data);
    }

    return $zone_data;
  }
}

For the country and regions. How to sort them alphabetically?
PS In php I am zero

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander null, 2018-02-16
@snikes

instead of order by country_id write order by country_name, region_name (the name of the field in which the country, region is stored)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question