elementdirect Posted January 26, 2006 Posted January 26, 2006 I'm putting together a small store using oscommerce. Since we'll only have a few products, the categories seemed like overkill. So I've created a new box type that displays all of the products in the database as links. You can see it in action at: http://www.elementdirect.com Since I'm new to php, I'd really appreciate it if someone could look at the code below and see if it makes sense. Is there a reference guide or other documentation about for database queries? The code is based on the information box and the "All Products" contribution: http://www.oscommerce.com/community/contributions,137 Thanks for the help. <?php $language_code = (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) ? $HTTP_GET_VARS['language'] : DEFAULT_LANGUAGE; $products_query = tep_db_query("SELECT p.products_id, pd.products_name, pc.categories_id FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id) ORDER BY pc.categories_id, pd.products_name"); $products_string = ''; while($products = tep_db_fetch_array($products_query)) { $products_string .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'] . (($language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $language_code))) . '">' . $products['products_name'] . "</a><br/>"; } $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_PRODUCTS); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('text' => $products_string); new infoBox($info_box_contents); ?> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.