RE: Ordering Products
iiinetworks <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.features |
|---|---|
| Message-ID | <d70649fa1f04d45ab0882c7abee64266@osCommerce-Forums> |
This message was sent from: Features
http://forums.oscommerce.com/viewtopic.php?p=195078#195078
----------------------------------------------------------------
After some off-forum correspondence, we ended up with this code: [code]<?php
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left',
'text' => 'BOX_HEADING_MAIN_PRODUCTS'
);
new infoBoxHeading($info_box_contents, true, false, tep_href_link(FILENAME_DEFAULT, '', 'NONSSL'));
$random_products_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_products_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 contentBox($info_box_contents);
?>[/code]