rendered paste bodyindex.php........global $used_img; $used_img[1]=0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / $MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; $used_imgs=implode(',',$used_img); $image = get_random_cat_image($categories['categories_id'],0,$used_imgs); array_push($used_img, '"' . $image . '"');echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $image, $categories['categories_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / $MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / $MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } }........random_cat_images.phpdefine('EMPTY_CAT_IMAGE', 'empty.gif');function get_random_cat_image($category_id, $count = 0, $used_imgs){ srand ((double)microtime()*1000000); $retun_val; if($category_id > 0 && tep_count_products_in_category_without_sub($category_id) > 0 && $count < 10) { $randInt = rand(1,10); $randStart = $randInt -1; $produkt_query = tep_db_query( "select distinct p.products_image as img ". "from products p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c ". "where p.products_id = pd.products_id and p.products_id = p2c.products_id and ". "p2c.categories_id = c.categories_id and '" . $category_id . "' in (c.categories_id, c.parent_id) and ". "p.products_image = p.products_image not in (" . $used_imgs . ")". " order by pd.products_viewed desc limit 3"); while($result = tep_db_fetch_array($produkt_query)) { $retun_val = $result['img']; if(rand(1,10) > 9) break; } if(!(tep_not_null($retun_val)) && tep_has_category_subcategories($category_id)) { $retun_val = get_random_cat_image_from_child($category_id,$count,$used_imgs); } } else if($category_id > 0 && tep_has_category_subcategories($category_id) && $count < 10) { $retun_val = get_random_cat_image_from_child($category_id,$count,$used_imgs); } else { $retun_val = EMPTY_CAT_IMAGE; } return $retun_val; }function get_random_cat_image_from_child($category_id,$count = 0){ $retun_val; $category_query = tep_db_query("select categories_id as ID from ". TABLE_CATEGORIES ." WHERE parent_id = ". $category_id ." LIMIT 0,". rand(1,10) ); while($ids = tep_db_fetch_array($category_query)) { $id = $ids['ID']; $retun_val = get_random_cat_image($id, $count++, $used_imgs); if((tep_not_null($retun_val)) && $retun_val != EMPTY_CAT_IMAGE) break; } return $retun_val;}//Changed from osCommerce function tep_count_products_in_category_without_sub($category_id, $include_inactive = false) { $products_count = 0; if ($include_inactive == true) { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'"); } else { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'"); } $products = tep_db_fetch_array($products_query); return $products['total'];} ?>*************************************The problem:Cuando index.php llama a la funtion get_random_cat_image() me devuelve valores duplicados. Hay algunos productos que se repiten en varias categorias pero yo le he implementado a mi manera como puedes ver un array en el cual se van introduciendo los valores ya tomados. Pero aun asi me duplica algunos.