Re: Ordering Products
iiinetworks <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.features |
|---|---|
| Message-ID | <1543dfff1fcb2913d45d1afc022247fb@osCommerce-Forums> |
This message was sent from: Features
http://forums.oscommerce.com/viewtopic.php?p=194979#194979
----------------------------------------------------------------
[code] $random_query = tep_db_query("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' order by rand() limit 9");
for ($row=0, $info_box_contents = array(); $row < 3;$row++ ) {
for ($col=0; $col < 3; $col++) {
$random_product = tep_db_fetch_array($random_query);
$random_product['products_name'] = tep_get_products_name($random_product['products_id']);
$random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']);
$info_box_contents[$row][$col] = array('align' => 'center',
'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $rprod_price);
}
}
new contentBoxHeading($info_box_contents);
[/code]I think that this should print 9 different items. It occurs to me that having the new statement inside the for loop was a mistake. I also simplified the logic by adding another loop.
Good luck,
Matt