Thread: SQL question

Page 5 of 7 FirstFirst ... 34567 LastLast
Results 41 to 50 of 68
  1. #41
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: SQL question

    Change this line
    PHP Code:
        if($col_count $col_max_item){ 
    to
    PHP Code:
        if($col_count >= $col_max_item){ 

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

    Default Re: SQL question

    PM sent

    getting there, but the page isn't loading correctly, perhaps a </div> issue?

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

    Default Re: SQL question

    There are several issues, some styling-related, some missing code snippets from the reorganization, some due to there being no content for certain manufacturers, and some I don't understand yet.
    I will have a modified bit for you soon, to handle the "no content" issue and a couple of others.

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

    Default Re: SQL question

    The ones with no content will be filled out as I update the products to fill out the fields that the code you've written uses.

    if you replace page_4 with page_3 on the URL i've PM'd you you can see the running total of how many products i still have to update.

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

    Default Re: SQL question

    I hope i've not caused you too much of a headache working on this :)

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

    Default Re: SQL question

    Actually, I'm learning a bunch of stuff about working with objects and refreshing some of my PHP in general, so it's good for me (if a bit of a headache while I learn:).

    I had to tweak the SQL to test it locally, because the pd.products_model_number field does not exist in stock ZC. I substituted products_model from the products table.

    It seems that $unique_model is not just an array with products_model and manufacturers_id fields, but a whole stew of stuff, so sizeof() doesn't work on it, returning just 1. You have to use $unique_model->RecordCount() to get that info. That explains why other ZC files do a processing step on query results to put them into a usable array.

    My latest version is here, and it appears to work in local testing.
    PHP Code:
    <?php
    //test by gjh42 2010-11-17 - :  http://www.zen-cart.com/forum/showthread.php?t=167959    second layout version - now updating in 139fresh
    //good for mfr lists that are all large
    // /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
    $content '<div id="modelList">' "\n";
    $manufacturers $db->Execute("SELECT manufacturers_name, manufacturers_id FROM " TABLE_MANUFACTURERS " ORDER BY manufacturers_name ASC");

    while (!
    $manufacturers->EOF) {
      
    $unique_model $db->Execute("SELECT DISTINCT pd.products_model_number, p.manufacturers_id 
                                    FROM " 
    TABLE_PRODUCTS_DESCRIPTION " pd LEFT JOIN " TABLE_PRODUCTS " p 
                                    ON pd.products_id = p.products_id 
                                    WHERE p.manufacturers_id = '" 
    $manufacturers->fields['manufacturers_id'] . "' 
                                    ORDER BY pd.products_model_number ASC"
    );
      
      
    //use this for stock zc
      //$unique_model = $db->Execute("SELECT DISTINCT products_model, manufacturers_id 
      //                              FROM " . TABLE_PRODUCTS . "  
      //                              WHERE manufacturers_id = '" . $manufacturers->fields['manufacturers_id'] . "' 
      //                              ORDER BY products_model ASC");
      
    $col_count 0;
      
    $content .= '<div class="mfrList">' "\n";
      
    $content .= '<h3>' .$manufacturers->fields['manufacturers_name']. '</h3>' "\n";
      
    $um_size=($unique_model->RecordCount());
      if(
    $unique_model->RecordCount()>0) {
        
    $col_max_item ceil($unique_model->RecordCount()/4);
        
    $content .= '<ul class="first">' "\n";
        while (!
    $unique_model->EOF) {
          if(
    $col_count >= $col_max_item){
            
    $col_count 0;
            
    $content .= '</ul>' "\n" '<ul>' "\n";
          }
          
    $content .= '  <li><a href="index.php?main_page=advanced_search_result&search_in_description=1 keyword=' .$unique_model->fields['products_model_number']. '" alt="alt name" />' .$unique_model->fields['products_model_number']. '</a></li>' "\n";
          
    $col_count ++;
          
    $unique_model->MoveNext();
        }
    //uniq
        
    $content .= '</ul>' "\n";
      }
    //size
      
    $content .= '<br class="clearBoth"></div>' "\n";
      
    $manufacturers->MoveNext();
    }
    //man
    $content .= '</div><br class="clearBoth">' "\n" '</div>' "\n";
    echo 
    $content;
    //EOF
     
    ?>
    <style>
    /*stylesheet rules*/
    #modelList {}
    .mfrList {margin: 0.5em; padding: 0.5em; border-bottom: 1px solid #aabbcc;}
    #modelList h3 {text-align: center;}
    #modelList ul {float: left; width: 24.5%; margin: 0; padding: 0; border-left: 1px solid #aabbcc;}
    #modelList ul.first {border: none;}
    #modelList li {list-style: /*none*/ inside; padding: 0 0 0 1.0em;}
    #modelList a {color: #0099cc;}
    </style>
    Last edited by gjh42; 18 Nov 2010 at 02:41 AM.

  7. #47
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: SQL question

    If you go to the same url I gave you before you can see the latest version, there still seems to be a problem with the page, I've had similar when there is one too many or not enough </div>

  8. #48
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: SQL question

    Fixed it I think, too last </div> out your code..

    $content .= '</div><br class="clearBoth">' . "\n" . '</div>' . "\n";
    echo $content;
    //EOF
    ?>

    became

    $content .= '</div><br class="clearBoth">' . "\n" . '' . "\n";
    echo $content;
    //EOF
    ?>

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

    Default Re: SQL question

    It wasn't causing a visible problem on my test installation (define_page_4 content), but yes, there was an extra </div> in there. That and its accompanying <br class="clearBoth" /> can be deleted from the file.

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

    Default Re: SQL question

    I see you are still getting a single blank first item in most but not all of the lists. My test (using the ZC demo items & mfr's) does not do this.

    Maybe it is caused by blank but not empty fields in your table?

 

 
Page 5 of 7 FirstFirst ... 34567 LastLast

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