pafranklin Posted October 6, 2018 Share Posted October 6, 2018 Hi all, I'm in the process of finishing a new bootstrap osc website, with the fantastic help from one of the members here and I have a question that I'm trying to sort myself around the display of manufacturers. Basically I want to sort the manufacturers so they display alphabetically. I've tried a few things but none have worked so wonder if someone could point me in the right direction please? My page so far is as follows: <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require('includes/languages/' . $language . '/manufacturers.php'); $breadcrumb->add(NAVBAR_TITLE, tep_href_link('manufacturers.php')); require('includes/template_top.php'); ?> <style> .cat-set2 { display: flex; flex-wrap:wrap; justify-content: space-between; } .cat-set2 > div { min-width:30%; margin: 10px; text-align: center; font-size: 30px; } .cat-image { background-color: white; min-width:30%; margin: 10px; padding:10px 0; text-align: center; font-size: 30px; border:1px solid #9a9a9a; border-radius:10px; } .cat-image:hover { border:1px solid #dd0000; } div.caption {background:white} </style> <div class="page-header"> <h1 class="h3"><?php echo HEADING_TITLE; ?></h1> </div> <?php //$manufacturers_query = tep_db_query("SELECT DISTINCT count(p2c.products_id) as prodcount, cd.categories_id, cd.categories_name, m.manufacturers_id, manufacturers_name, manufacturers_image FROM " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_MANUFACTURERS ." m, " . TABLE_PRODUCTS_TO_CATEGORIES ." p2c WHERE p.manufacturers_id = m.manufacturers_id AND p.products_id = p2c.products_id AND p.products_status = 1 AND p2c.categories_id = c.categories_id and c.categories_id = cd.categories_id and cd.language_id = " . (int)$languages_id . " GROUP BY m.manufacturers_name, cd.categories_name"); $db_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image from manufacturers m left join manufacturers_info mi on m.manufacturers_id = mi.manufacturers_id where mi.languages_id = '" . (int)$languages_id . "'"); ?> <div class="contentContainer"> <div class="contentText"> <div><?php echo TEXT_INFORMATION; ?></div> <div class=" cat-set2"> <?php while ($db = tep_db_fetch_array($db_query)) { echo '<div>'; echo '<div class="cat-image equal-height" style="margin-bottom:0;">'; echo '<div class="text-center">'; echo '<a href="' . tep_href_link('index.php', 'manufacturers_id=' . $db['manufacturers_id']) . '">' . tep_image('images/' . $db['manufacturers_image'], htmlspecialchars($db['manufacturers_name']), '100', '100') . '</a>'; echo '</div>'; echo '</div>'; echo '<div class="caption text-center">'; echo '<h5><a href="' . tep_href_link('index.php', 'manufacturers_id=' . $db['manufacturers_id']) . '"><span itemprop="itemListElement">' . $db['manufacturers_name'] . '</span></a></h5>'; echo '</div>'; echo '</div>'; } ?> </div> </div> <div style="clear:both;"></div> <div class="buttonSet"> <div class="text-right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'fa fa-angle-right', tep_href_link('index.php')); ?></div> </div> </div> <?php require('includes/template_bottom.php'); require('includes/application_bottom.php'); ?> You will never learn if you don't try. And boy am I trying....! Link to comment Share on other sites More sharing options...
♥JcMagpie Posted October 6, 2018 Share Posted October 6, 2018 You need to use the sql "order" to do the leg work for you first. Then its just a case of using it. You will probably find all you need in this post. order by manufacturers_name Link to comment Share on other sites More sharing options...
pafranklin Posted October 8, 2018 Author Share Posted October 8, 2018 Thank you for the reply. Its that first aspect I'm struggling with. You will never learn if you don't try. And boy am I trying....! Link to comment Share on other sites More sharing options...
♥JcMagpie Posted October 8, 2018 Share Posted October 8, 2018 Just use what is already in the software! The manufacturers box already sorts by name. $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.