Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default how to print sql query to screen?

    I have a bit of code that I'm trying to upgrade to 1.3.8/9. I'm trying to put in a drop down box populated from a table - a simple list of months and month id.

    When I add in the db execute statement, the page stops but no error message is generated in the cache. I want to see the query but don't recall how to print the query to the screen.

    I suspect there's other things wrong with this code but this was the first thing I wanted to check.

    By the way this code is going in the template file - tpl_index_product_list.php and am fully aware this is not how it's usually done - having all of the is code there. However, just trying to get this to work where the original changed code was before.

    The cart is 1.3.9g.

    Here is the code:

    if(isset($_GET['filter_month_id']))
    {
    $selected_month=$_GET['filter_month_id'];
    }
    $months_query = $db->Execute("select * from month");
    $monthList = $db->Execute($months_query);

    if ($monthList->RecordCount()>0) {
    $number_of_rows = $monthList->RecordCount()+1;
    $monthList_array = array();
    }

    while (!$monthList->EOF) {
    $month_name = $monthList->fields['month_name'];
    $monthList_array[] = array('id' => $monthList->fields['month_id'],
    'text' => $month_name);
    $monthList->MoveNext();
    }

    zen_draw_pull_down_menu('filter_month_id', $monthList_array, (isset($_GET['filter_month_id']) ? $_GET['filter_month_id'] : ''), 'onchange="this.form.submit();"') . zen_hide_session_id();
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: how to print sql query to screen?

    $months_query = $db->Execute("select * from month");
    $monthList = $db->Execute($months_query);
    Why are you executing the results of an already executed query?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: how to print sql query to screen?

    Gads, thank you for the fresh eyes. Sometimes I think I just need to hire someone to review my code for idiocies like that. Now let's see if it will work.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  4. #4
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: how to print sql query to screen?

    and it is conquered. Thanks so much for the quick response!
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  5. #5
    Join Date
    Jun 2011
    Posts
    22
    Plugin Contributions
    0

    Default Re: how to print sql query to screen?

    I want to fetch more field data from DB, so i want to know in which file i have to add field name???

  6. #6
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: how to print sql query to screen?

    That's a long conversation and then it may be such a long answer that you would have trouble getting a complete answer.

    What field and for what purpose?
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

 

 

Similar Threads

  1. v151 SQL query setup. How do I TEST a query 'off-line'?
    By lewisasding in forum General Questions
    Replies: 3
    Last Post: 8 Mar 2013, 12:24 AM
  2. v150 Create Report - SQL Query not working in ZC screen (in DB ok)
    By iris - karen in forum Basic Configuration
    Replies: 3
    Last Post: 22 Jun 2012, 05:55 AM
  3. how to do a SQL query?
    By therealex in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 12 Dec 2009, 11:52 PM
  4. How to insert products by SQL query?
    By zildjian in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 28 Feb 2009, 12:47 AM
  5. How would I do this with an sql query?
    By member in forum General Questions
    Replies: 2
    Last Post: 22 Mar 2008, 05:47 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