Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Displaying Manufacturer/Author Name


iwik

Recommended Posts

Hey there,

 

I've been battling this for a couple of days now, and thought I might see if any of you know the answer.

 

I'm well aware my SQL skills aren't so hot, so I've probably made some major boo-boo somewhere in my coding.

 

What I'm trying to do is make the manufacturer (or author) name show up in the listings along with the product image, name and price.

 

So far, everything else will show up ok but "Resource id #50" is displayed instead of the name - the number on the end varies with each product.

 

So far I have added 'p.authors_id' to the featured_products_query as follows:

$featured_products_query = tep_db_query("select p.products_id, p.products_image, p.authors_id, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 } else {
   $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name));
   $featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.authors_id, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);
 }

 

and then in the display information have added..

 

  while ($featured_products = tep_db_fetch_array($featured_products_query)) {
   $num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); }
   $featured_products['products_name'] = tep_get_products_name($featured_products['products_id']);

// -- Get the authors name, comparing authors_id in the authors table to authors_id in the products table -- 
    $featured_products['authors_name'] = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . $featured_products['authors_id'] . "'");

 

And I'm displaying the $featured_products['authors_name'] variable.

 

Can anyone see where I've gone wrong in my sql? If you'd rather I posted the whole file let me know, but it's only these two bits that I've changed/added.

 

Thanks,

 

Jane.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...