Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    319
    Plugin Contributions
    0

    Default help with database query selecting manufacturers

    hi,
    building my megamenu and if you check here

    http://bicycles.stuff-4-sale.org

    if you hover over bikes you will see what im talking about. i want 3 columns of categories and one with the manufacturers, but i only want manufacturers that are connected to the categoies shown.

    PHP Code:
    <?php
            
      $show_manufacturers
    true;

    // for large lists of manufacturers uncomment this section
    /*
      if (($_GET['main_page']==FILENAME_DEFAULT and ($_GET['cPath'] == '' or $_GET['cPath'] == 0)) or  ($request_type == 'SSL')) {
        $show_manufacturers= false;
      } else {
        $show_manufacturers= true;
      }
    */

    // Set to true to display manufacturers images in place of names
    define('DISPLAY_MANUFACTURERS_IMAGES',true);

    if (
    $show_manufacturers) {

    // only check products if requested - this may slow down the processing of the manufacturers sidebox
      
    if (PRODUCTS_MANUFACTURERS_STATUS == '1') {
        
    $manufacturer_sidebox_query "select distinct m.manufacturers_id, m.manufacturers_name, m.manufacturers_image
                                from " 
    TABLE_MANUFACTURERS " m
                                left join " 
    TABLE_PRODUCTS " p on m.manufacturers_id = p.manufacturers_id
                                left join " 
    TABLE_PRODUCTS_TO_CATEGORIES " c on p.products_id = c.products_id
                                where m.manufacturers_id = p.manufacturers_id and p.products_status= 1 and c.categories_id = 963
                                order by manufacturers_name"
    ;
      } else {
        
    $manufacturer_sidebox_query "select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image
                                from " 
    TABLE_MANUFACTURERS " m
                                order by manufacturers_name"
    ;
      }

      
    $manufacturer_sidebox $db->Execute($manufacturer_sidebox_query);

      if (
    $manufacturer_sidebox->RecordCount()>0) {
        
    $number_of_rows $manufacturer_sidebox->RecordCount()+1;

    // Display a list
        
    $manufacturer_sidebox_array = array();
    //        kuroi: commented out to avoid starting list with text scrolling list entries such as "reset" and "please select"
    //    if (!isset($_GET['manufacturers_id']) || $_GET['manufacturers_id'] == '' ) {
    //      $manufacturer_sidebox_array[] = array('id' => '', 'text' => PULL_DOWN_ALL);
    //    } else {
    //      $manufacturer_sidebox_array[] = array('id' => '', 'text' => PULL_DOWN_MANUFACTURERS);
    //    }

        
    while (!$manufacturer_sidebox->EOF) {
          
    $manufacturer_sidebox_name = ((strlen($manufacturer_sidebox->fields['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturer_sidebox->fields['manufacturers_name'], 0MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' $manufacturer_sidebox->fields['manufacturers_name']);
          
    $manufacturer_sidebox_image $manufacturer_sidebox->fields['manufacturers_image'];
          
    $manufacturer_sidebox_array[] =
            array(
    'id' => $manufacturer_sidebox->fields['manufacturers_id'],
                  
    'text' => DISPLAY_MANUFACTURERS_IMAGES ?
                    
    zen_image(DIR_WS_IMAGES $manufacturer_sidebox_image$manufacturer_sidebox_name) :
                    
    $manufacturer_sidebox_name);
          
    $manufacturer_sidebox->MoveNext();
        }
          
      }
    // $show_manufacturers
                    
    for ($i=0;$i<sizeof($manufacturer_sidebox_array);$i++) {
          
    $content '';
          
    $content .= '<li><a class="hide" href="' zen_href_link(FILENAME_DEFAULT'manufacturers_id=' $manufacturer_sidebox_array[$i]['id']) . '">';
          
    $content .= $manufacturer_sidebox_array[$i]['text'];
          
    $content .= '</a></li>' "\n";
          echo 
    $content;
        }
    ?>
    so i am using
    PHP Code:
    and c.categories_id 963 
    but want multiple categories like 963 / 964 or as these are subcategories the main category

    hope this makes sense

    thanks
    bn

  2. #2
    Join Date
    Apr 2010
    Posts
    319
    Plugin Contributions
    0

    Default Re: help with database query selecting manufacturers

    now sorted using

    c.categories_id in (963,964,478)

    unless there is a better way

    bn

 

 

Similar Threads

  1. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  2. v154 Quick help with MySQL Query - Selecting OLD Product at Random
    By Jeff_Mash in forum Setting Up Specials and SaleMaker
    Replies: 21
    Last Post: 24 Nov 2015, 12:05 AM
  3. Database query help?
    By filmfr3ak in forum General Questions
    Replies: 4
    Last Post: 17 Sep 2009, 04:24 PM
  4. Help with selecting new template from list?
    By laurieudy in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 21 Jun 2009, 01:29 AM
  5. Adding multiple products to the database with a mySQL query
    By hiltunna in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 26 Jul 2007, 05:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR