Thread: SQL question

Page 7 of 7 FirstFirst ... 567
Results 61 to 68 of 68
  1. #61
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: SQL question

    Change your ist-style to inside to get your bullets contained inside the dropdown background.

    #modelList ul {float: left; width: 24.5%; margin: 0; padding: 0; border-left: 1px solid #aabbcc;list-style: inside;}

  2. #62
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: SQL question

    Done that, have a look....

  3. #63
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: SQL question

    What happened? It worked fine when I tested it on your site.

    You didn't just drop in that bit verbatim, did you? It was intended to show where to add the property to the existing rule, and the absense of a closing } would cause problems as a standalone rule.

  4. #64
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: SQL question

    try now, I was adjusting the code.

    I presume that search engines will be able to read it just the same even though it is hidden?

  5. #65
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: SQL question

    On a side note what you think of the site? I've not ever put it up for critique, but feedback is welcome.

  6. #66
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: SQL question

    Why that's beeyoutyful! (As a boss of mine used to say:) Very nice styling of the list, and works great. The alt text is well used.

    I'm not a search engine expert, but I don't think they will have problems seeing the links. Dropdown CSS category menus like this are widely used.

    The site overall is gorgeous. The fixed fall foliage/sky background sets a pleasant tone just being on the site, and the functional parts are stylish but unobtrusive. I haven't looked all around the site, but what I have seen looks clear, informative and easy to use.

  7. #67
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: SQL question

    I was bothered by the inefficient use of SQL queries (one per manufacturer, plus one; could be dozens or hundreds of queries just for this list), so I did some studying of MySQL and recoded it to operate with just one query to fetch all the information. It is then processed into a multi-level array, which is output to the set of lists as before. I have added some defines for flexibility.

    As posted, it will give a vertical manufacturer list with dropdown product lists in three columns, but with a define change and a few styling changes, it will be a horizontal manufacturer list with dropdown vertical product lists.
    PHP Code:
    <?php 
    //test by gjh42 2010-11-30 - working:  http://www.zen-cart.com/forum/showthread.php?t=167959    second sql/code version - now updating in 139fresh
    // /includes/modules/your_template/model_list2.php

    //   include(DIR_WS_MODULES . zen_get_module_directory(model_list2.php));//put in location file - not working
    //   include(DIR_WS_MODULES . 'your_template/model_list2.php');//put in location file

    //includes/languages/english/extra_definitions/your_template/model_list_defines.php
    define('MODEL_LIST_COLS'3);
    define('MODEL_LIST_EMPTIES''');//to eliminate empty mfr lists comment this and uncomment next line
    //define('MODEL_LIST_EMPTIES', ' and p.products_model IS NOT NULL');
    define('MODEL_LIST_MFR_COMMENT''<br /><span class="mfrComment"> hover for models</span>');
    define('MODEL_LIST_ALT_LINK''Click to search for ');
    //EOF defines

    $model_list_sql 'SELECT DISTINCT p.products_model, p.manufacturers_id, m.manufacturers_name
                                 FROM ' 
    TABLE_PRODUCTS ' p, ' TABLE_MANUFACTURERS ' m
                                 WHERE m.manufacturers_name IS NOT NULL 
                                 AND p.manufacturers_id = m.manufacturers_id' 
    MODEL_LIST_EMPTIES '
                                 ORDER BY m.manufacturers_name, p.products_model'
    ;
    $model_list_query $db->Execute($model_list_sql);
    $current_mfr '';
    while (!
    $model_list_query->EOF) {
      if (
    $model_list_query->fields['manufacturers_name'] != $current_mfr) {
        
    $current_mfr $model_list_query->fields['manufacturers_name'];
        
    $model_list[$current_mfr]['mfrs_id'] = $model_list_query->fields['manufacturers_id'];
      }
      
    $model_list[$current_mfr]['products_model'][] = $model_list_query->fields['products_model'];
      
    $model_list_query->MoveNext();
    }
    $content '<div id="modelList">' "\n";
    foreach (
    $model_list as $mfr_key=>$current_mfr) {
      
    $col_count 0;
      
    $mfrs_name $mfr_key;
      
    $content .= '<div class="mfrList">' "\n";
      
    $content .= '<h3><a href="index.php?main_page=advanced_search_result&search_in_description=1&keyword=' $mfrs_name '" title="' MODEL_LIST_ALT_LINK $mfrs_name '">' $mfrs_name '</a>' MODEL_LIST_MFR_COMMENT '</h3>' "\n";
      
    $list_size count($model_list[$mfr_key]['products_model']);
      if(
    $list_size) {
        
    $col_max_item ceil($list_size/MODEL_LIST_COLS);
        
    $col_width ' style="width:' 99/MODEL_LIST_COLS '%;"';
        
    $content .= '<div class="mfrListCols"><ul class="first"' $col_width '>' "\n";
        for (
    $i=0;$i<$list_size;$i++) {
          if(
    $col_count >= $col_max_item){
            
    $col_count 0;
            
    $content .= '</ul>' "\n" '<ul' $col_width '>' "\n";
          }
          
    $current_model $model_list[$mfr_key]['products_model'][$i];
          
    $content .= '  <li><a href="index.php?main_page=advanced_search_result&search_in_description=1&keyword=' $current_model '" title="' MODEL_LIST_ALT_LINK $current_model '">' $current_model '</a></li>' "\n";
          
    $col_count ++;
        }
        
    $content .= '</ul></div>' "\n";
      }
    //size
      
    $content .= '<div class="clearBoth"></div></div>' "\n";
    }
    //foreach
    $content .= '</div>' "\n";
    echo 
    $content;
    //EOF
     
    ?>
    <style>
    /*stylesheet rules*/
    #modelList {}
    .mfrList {margin: 0; padding: 0; border-bottom: 1px solid #aabbcc; position: relative; /*float: left; width: 33%;*/}
    #modelList h3 {text-align: left;}
    #modelList h3 a {}
    .mfrComment {font-size: 0.7em; font-weight: normal; color: #aabbcc; margin-left: 1.0em;}
    #modelList ul {float: left; margin: 0; padding: 0;}
    #modelList ul.first {}
    #modelList li {list-style: inside; padding: 0 0 0 0.2em; color: #990000;}
    #modelList a {color: #0099cc;}
    .mfrListCols {display: none;}
    .mfrList:hover .mfrListCols {display: block; position: absolute; z-index: 100; width: 98.7%; background: #ffffee; padding: 0.5em 0 0.5em 0.5em; border-bottom: 1px solid #aabbcc;}
    </style>
    Once it has a bit more testing by others, I will separate it out into the proper component files and package it up as a mod. Please let me know if you test it.

  8. #68
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: SQL question

    Model List has been submitted to Free Addons. The support thread and interim location of the zip is here.

    I have added the ability to display either product names or model numbers (sorted alphabetically in either case).

 

 
Page 7 of 7 FirstFirst ... 567

Similar Threads

  1. v154 SQL Script Question
    By Feznizzle in forum General Questions
    Replies: 2
    Last Post: 2 Jul 2015, 07:13 PM
  2. SQL question
    By timhersh in forum General Questions
    Replies: 14
    Last Post: 1 Oct 2012, 10:12 PM
  3. SQL question
    By pixelpadre in forum General Questions
    Replies: 9
    Last Post: 26 Apr 2012, 02:14 PM
  4. v139h SQL question... help please!
    By Feznizzle in forum General Questions
    Replies: 4
    Last Post: 3 Mar 2012, 10:31 PM
  5. SQL Question Deleting zones
    By kitcorsa in forum General Questions
    Replies: 2
    Last Post: 12 May 2008, 12:37 PM

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