Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how to add category name to product_info page


spencermjax

Recommended Posts

Posted

I have figured out how to add some items from the database to my pages but now I would like to add the category or sub category to my page. How do I do that? This is how I am doing it for the other info.

 

<?= $product_info['products_name']?>

 

The problem is that I only see a category id and not a category name in the database.

Posted

I have found the table that contains the category names (categories_description).

Here is the code that gathers the product_info info to be displayed.

 

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);

 

How would I rewrite that code to include the category that a product is in so I could display it on the product_info page?

Posted

I have now modified it to select the category name but I don't know how to get the correct category according to the product being viewed. the code below simply gets the first category name in the category_descriptions table

 

$product_info_query = tep_db_query("select pdd.categories_name, p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_CATEGORIES_DESCRIPTION  . " pdd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);

Archived

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

×
×
  • Create New...