Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

No errors from query, but no output


Guest

Recommended Posts

Posted

I'm writing a modification that I need for my site. I'm still learning OSC's way of doing things, so please bear with me. I've checked the query raw against my db, so I know that the "base" query is correct. I had an error,but found it and corrected it, but when I run it I get this lonely "0" off to the right.

 

I'll paste the query, but what I'm wondering, is do I need to create a function in general for this to work? In the last I app I worked with there was one primary functions file (about 40k lines of code) and all events in the app had to have a function created there to work correctly.

 

All this query is to do, is grab the varible of the product_id from the url, which the prior page is delivering that correctly and display a list of all the customers that bought that product. Now, in my terms, products are events and customers are attendees, but the premise is exactly the same. product_id = event_id. Someone else was gracious enough to look at this for me who is much more knowledgable of OSC than me and he is stummped also. There is test data for the query to pull. Any suggestions would really be appreciated.

 

The URL that the VAR is grabbed from looks like this:

.../attendee_listing.php?page=1&products_id=43

 

<!-- Begin Attendee_listing //-->

<?php

if ($HTTP_GET_VARS['page'] > 1){

$rows = $HTTP_GET_VARS['page'];

$pID = 0;

}

 

if (isset($HTTP_GET_VARS['pID']))

{

$pID = $HTTP_GET_VARS['pID'];

}

$attendee_query_raw = "select c.customers_firstname, c.customers_id, c.customers_gender, op.products_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS . " o WHERE c.customers_id = 'o.customers_id' AND o.orders_id = 'op.orders_id' and op.products_id = '" . $pID . "' group by c.customers_firstname order by c.customers_gender";

$attendee_split = new splitPageResults($HTTP_GET_VARS['pID'], MAX_DISPLAY_ATTENDEE_LISTING, $attendee_query_raw, $attendee_query_numrows);

$attendee_query_numrows = tep_db_query("select customers_id from " . TABLE_ORDERS . " group by customers_id");

$attendee_query_numrows = tep_db_num_rows($attendee_query_numrows);

 

$attendee_query = tep_db_query($attendee_query_raw);

while ($attendee = tep_db_fetch_array($attendee_query)) {

$rows++;

 

}

if (strlen($rows) < 2) {

$rows = '0' . $rows;

}

?>

<td class="dataTableContent"><?php echo $rows; ?>.</td>

<td class="dataTableContent"><?php echo $attendee['customers_firstname'] . ' ' . $attendee['customer_id'] . '</a>'; ?></td>

 

</tr>

<?php

 

?>

Posted

Really????????????

 

I never even thought of that!!!!!!! If this works I'm going to feel soooooo dumb :oops:

Posted

I change pID to product_id throughout the query and it made no difference. I still have this lonely zero and it should deliver a list of four people in a simple table.

 

Any other ideas? :cry:

Posted

put

 

echo $attendee_query_raw;

 

and run the SQL output through phpMyAdmin - looks to me you are getting no results back - which I suspect is because pId has no value

Posted

BTW did you try products_id rather than product_id - type in first message

Posted

I was away from my computer for a few minutes. But yes products vs product, just a typo. I'll try your next idea.

 

Thanks for working with me.

 

Ruth in AZ

Posted

I think you lost me a bit. When I ran the query in standard SQL through the admin, it gives me the list of the attendees.

 

I'm sorry can you eleborate?

Posted

Ok, well at least something is printing on the page now, but its the actual query in php, not the output. Boy I have a mess.

Posted

I went back once again to be sure my query was correct and it is. The only thing I did differently was substitute an actual number for the pID which was the same as was trying to be passed by the VARS and I got the right output.

 

So I'm back to square one.

 

Anyone else?

Posted

Remove the single quote from your where clause (except for the pID portion).

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted

In other words,

  $attendee_query_raw = "select c.customers_firstname, c.customers_id, c.customers_gender, op.products_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS . " o WHERE c.customers_id = o.customers_id AND o.orders_id = op.orders_id and op.products_id = '" . $pID . "' group by c.customers_firstname order by c.customers_gender";

If you remove line 82,

  $attendee_split = new splitPageResults($HTTP_GET_VARS['pID'], MAX_DISPLAY_ATTENDEE_LISTING, $attendee_query_raw, $attendee_query_numrows);

you will get your output.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted

Change the split page line to:

  $attendee_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_ATTENDEE_LISTING, $attendee_query_raw, $attendee_query_numrows);

and it should work

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...