Zen Cart Logo
Forums / General Questions / how to print sql query to screen?

how to print sql query to screen?

Views: 2,580

Results 1 to 6 of 6
11 Oct 2010, 12:45 PM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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();
11 Oct 2010, 12:57 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

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? :blush:

11 Oct 2010, 1:23 PM
#3
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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.

11 Oct 2010, 2:00 PM
#4
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: how to print sql query to screen?

and it is conquered. Thanks so much for the quick response!

15 Jun 2011, 10:03 AM
#5
nitesh107 avatar

nitesh107

New Zenner

Join Date:
Jun 2011
Posts:
22
Plugin Contributions:
0

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???

15 Jun 2011, 11:40 AM
#6
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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?