
Originally Posted by
DrByte
I don't understand what you're trying to do with the code you posted.
I forgot to post up the MySQL coding that I put in header.php
PHP Code:
$featured_products_query = "SELECT feature.products_id, product_info.products_image, product_info.products_price, product_desc.products_name FROM " . TABLE_FEATURED . " as feature, " . TABLE_PRODUCTS . " as product_info, " . TABLE_PRODUCTS_DESCRIPTION . " as product_desc, " . TABLE_PRODUCTS_TO_CATEGORIES . " as ptc WHERE feature.products_id = product_info.products_id AND feature.products_id = product_desc.products_id and feature.products_id = ptc.products_id AND ptc.categories_id = :categoriesID ORDER BY rand() LIMIT 3";
$featured_products_query = $db->bindVars($featured_products_query, ':categoriesID', $current_category_id, 'integer');
$featured_products = $db->Execute($featured_products_query);
Essentially, look at featured products for all products within a given category (the category that the user is looking at). Select three at random and return the row values as defined above. (Product ID, image, price, and name).
The code in the original post, generally cycles through the data and returns the row values for it.