Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36
  1. #1
    Join Date
    Aug 2012
    Posts
    106
    Plugin Contributions
    0

    Default Need help with a query

    I created a page from the ezpages for my manufacturers. I have over 300. What I would like to do is have A-Z at the top, and then a section for each letter and have the query list all manufacturers for that letter but I have no clue how to go about it.

    This is what I had in mind:
    Name:  manufacturers.jpg
Views: 212
Size:  37.8 KB

    Can anyone assist with a script?

    Thanks,

    Clint

  2. #2
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Need help with a query

    I don't have allot of time to go into detail, maybe someone else can chime in in my absence but this should get you started.

    I put this right in the define page:

    PHP Code:
    <?php

        
    for ($i=65$i<91$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }
        for (
    $i=48$i<58$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }

    echo 
    '<br class="clearBoth" />';


    $manufacturers_query "SELECT distinct manufacturers_id, manufacturers_name FROM " TABLE_MANUFACTURERS " ORDER BY manufacturers_name"

    $manufacturers $db->Execute($manufacturers_query);

    while (!
    $manufacturers->EOF) {

        if (
    $initial !== strtoupper(substr($manufacturers->fields['manufacturers_name'], 01))) {
            
    $initial strtoupper(substr($manufacturers->fields['manufacturers_name'], 01));
            echo 
    '<a name="#'.$initial.'">' $initial '</a><br />----------<br />';
        }
        echo 
    $manufacturers->fields['manufacturers_name'] . '<br />';

          
    $manufacturers->MoveNext();
        }
    ?>

  3. #3
    Join Date
    Aug 2012
    Posts
    106
    Plugin Contributions
    0

    Default Re: Need help with a query

    Quote Originally Posted by rbarbour View Post
    I don't have allot of time to go into detail, maybe someone else can chime in in my absence but this should get you started.

    I put this right in the define page:

    PHP Code:
    <?php

        
    for ($i=65$i<91$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }
        for (
    $i=48$i<58$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }

    echo 
    '<br class="clearBoth" />';


    $manufacturers_query "SELECT distinct manufacturers_id, manufacturers_name FROM " TABLE_MANUFACTURERS " ORDER BY manufacturers_name"

    $manufacturers $db->Execute($manufacturers_query);

    while (!
    $manufacturers->EOF) {

        if (
    $initial !== strtoupper(substr($manufacturers->fields['manufacturers_name'], 01))) {
            
    $initial strtoupper(substr($manufacturers->fields['manufacturers_name'], 01));
            echo 
    '<a name="#'.$initial.'">' $initial '</a><br />----------<br />';
        }
        echo 
    $manufacturers->fields['manufacturers_name'] . '<br />';

          
    $manufacturers->MoveNext();
        }
    ?>
    Thank you!

    What do you mean by put it in the define page? If I created the page with EZ-Page, where do I find it?

    Clint

  4. #4
    Join Date
    Aug 2012
    Posts
    106
    Plugin Contributions
    0

    Default Re: Need help with a query

    Quote Originally Posted by rbarbour View Post
    I don't have allot of time to go into detail, maybe someone else can chime in in my absence but this should get you started.

    I put this right in the define page:

    PHP Code:
    <?php

        
    for ($i=65$i<91$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }
        for (
    $i=48$i<58$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }

    echo 
    '<br class="clearBoth" />';


    $manufacturers_query "SELECT distinct manufacturers_id, manufacturers_name FROM " TABLE_MANUFACTURERS " ORDER BY manufacturers_name"

    $manufacturers $db->Execute($manufacturers_query);

    while (!
    $manufacturers->EOF) {

        if (
    $initial !== strtoupper(substr($manufacturers->fields['manufacturers_name'], 01))) {
            
    $initial strtoupper(substr($manufacturers->fields['manufacturers_name'], 01));
            echo 
    '<a name="#'.$initial.'">' $initial '</a><br />----------<br />';
        }
        echo 
    $manufacturers->fields['manufacturers_name'] . '<br />';

          
    $manufacturers->MoveNext();
        }
    ?>
    Thank you!

    What do you mean by put it in the define page? If I created the page with EZ-Page, where do I find it?

    Clint

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,886
    Plugin Contributions
    96

    Default Re: Need help with a query

    EZ-pages can't include imbedded PHP; that's where the "simple" pages like the "About Us Page" (available for download in the Plugins section) come in. rbarbour was referring to the language-specific page that can be edited via Tools->Define Pages Editor and included in one of those "simple" pages.

  6. #6
    Join Date
    Aug 2012
    Posts
    106
    Plugin Contributions
    0

    Default Re: Need help with a query

    Quote Originally Posted by lat9 View Post
    EZ-pages can't include imbedded PHP; that's where the "simple" pages like the "About Us Page" (available for download in the Plugins section) come in. rbarbour was referring to the language-specific page that can be edited via Tools->Define Pages Editor and included in one of those "simple" pages.
    Ok, now I'm following. So if I use page_3, how do I rename it and get the url?

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,886
    Plugin Contributions
    96

    Default Re: Need help with a query

    If you use page_3, that page's name will (unfortunately) be page_3. That's where the "About Us" page plugin comes in.

    That plugin identifies the set of files necessary to create an about_us page and you could use its file structure as a model to create a manufacturers_map page ... or whatever you desire your page to be named.

  8. #8
    Join Date
    Aug 2012
    Posts
    106
    Plugin Contributions
    0

    Default Re: Need help with a query

    OK great. Thank you. Can you take a look at the code he gave me and help modify it to what I am looking for?

    http://tacticaloffense.com/store/ind...in_page=page_3

    I need for each letter in the header to move down to the letter of the manufacturers, and then turn the list of manufacturers in to links to product listings for those manufacturers.

    Is that something you can help with?

  9. #9
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Need help with a query

    Quote Originally Posted by clint6998 View Post
    OK great. Thank you. Can you take a look at the code he gave me and help modify it to what I am looking for?

    http://tacticaloffense.com/store/ind...in_page=page_3

    I need for each letter in the header to move down to the letter of the manufacturers, and then turn the list of manufacturers in to links to product listings for those manufacturers.

    Is that something you can help with?
    Was going to ask if you were okay with the vertical list created or not, looks like not. Are you hard pressed for the horizontal alphabetization or would vertically alphabetized be sufficient? (Obviously ideal would be able to handle both.)

    The first part of the provided solution is somewhat browser dependent as it currently uses internal links to shift the page to the selected "letter" but not all browsers (versions within browser) support that unfortunately. As to the manufacturer link being clickable, the information is present in the query and just need to generate a correct link using zen_html_ref as the function to return the formatted link and wrap the manufacturer with the html for a link.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Need help with a query

    PHP Code:
    <?php

        
    for ($i=65$i<91$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }
        for (
    $i=48$i<58$i++) {
        echo 
    '<a href="'.chr($i).'">' chr($i) . '</a>';
        }

    echo 
    '<br class="clearBoth" />';


    $manufacturers_query "SELECT distinct manufacturers_id, manufacturers_name FROM " TABLE_MANUFACTURERS " ORDER BY manufacturers_name"

    $manufacturers $db->Execute($manufacturers_query);

    while (!
    $manufacturers->EOF) {

        if (
    $initial !== strtoupper(substr($manufacturers->fields['manufacturers_name'], 01))) {
            
    $initial strtoupper(substr($manufacturers->fields['manufacturers_name'], 01));
            echo 
    '<a name="#'.$initial.'">' $initial '</a><br />----------<br />';
        }
        
    ?><a href="<?php echo zen_href_link(FILENAME_DEFAULT'manufacturers_id=' . (int) $manufacturers->fields['manufacturers_id'], $request_type); ?>" ><?php echo $manufacturers->fields['manufacturers_name']; ?></a><br /><?php

          $manufacturers
    ->MoveNext();
        }
    ?>
    The above has been modified to add the manufacturer's link using the existing vertical formatting. The click from letter to section remains as was provided.
    Last edited by mc12345678; 9 Mar 2016 at 05:30 PM. Reason: oops, had an extra parameter in zen_href_link.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 1 of 4 123 ... LastLast

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. Need help creating SQL query...
    By DigitalShadow in forum General Questions
    Replies: 2
    Last Post: 22 Jun 2011, 02:05 PM
  3. Need help with a mySQL Query
    By jeffmic in forum General Questions
    Replies: 3
    Last Post: 19 Dec 2010, 02:21 PM
  4. Need help with SQL query. Want to make membership that expires.
    By TecBrat in forum Managing Customers and Orders
    Replies: 1
    Last Post: 18 Jun 2010, 03:43 PM
  5. Need help w/ SQL query in phpMyAdmin
    By audradh in forum General Questions
    Replies: 17
    Last Post: 16 Nov 2009, 01:05 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