Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Date added order for other products


Recommended Posts

On product_info.php ive got other_products.php for related products, however by default it displays random results i think defined by ORDER BY RAND io would assume changing this to ORDER BY ASC would change it but it doesnt, any suggestions would be most welcome!

 

 

<?php
$other_products_result = tep_db_query("SELECT `pr`.*, `pd`.*, `ma`.* FROM `products` `pr` LEFT JOIN `products_description` `pd` ON `pr`.`products_id` = `pd`.`products_id` LEFT JOIN `manufacturers` `ma` ON `pr`.`manufacturers_id` = `ma`.`manufacturers_id` WHERE `pr`.`manufacturers_id` = '".$product_info['manufacturers_id']."' AND `pr`.`products_status` = 1 ORDER BY RAND()");

$manufacturers_name_query = tep_db_query("SELECT `manufacturers_name` FROM `manufacturers` WHERE `manufacturers_id` = '".$product_info['manufacturers_id']."';");

$manufacturers_name = tep_db_fetch_array($manufacturers_name_query);

echo "<h4 class=\"moreProducts\"><a href=\"" . tep_href_link(FILENAME_DEFAULT, "manufacturers_id=" . $product_info['manufacturers_id']) . "\">View all ".$manufacturers_name['manufacturers_name']."</a> | <a href=\"" . tep_href_link('size_charts.php') . "\">Size Chart Info</a></h4>";

//<a href="http://www.primedelux.com/size_charts.php">Size Chart Info</a>

echo "<table id=\"topImages\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";

//Start a counter to split the rows
$row_counter = 0;

while($other_products = tep_db_fetch_array($other_products_result)) {

if($row_counter == 0) {

	echo "<tr>";

}

echo "<td>";
echo "<div><a href=\"" . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $other_products['products_id']) . "\">".tep_image(DIR_WS_IMAGES.$other_products['products_image_med'], $other_products['manufacturers_name']." ".$other_products['products_name'], '155', '155')."</a>";
echo "<p><a href=\"" . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $other_products['products_id']) . "\">".$other_products['products_name']."</a></p></div>";
echo "</td>";

if($row_counter == 4) {

	echo "</tr>";

	$row_counter = 0;

} else {

	$row_counter++;

}

}

if($row_counter != 0) {

echo "</tr>";

}

echo "</table>";

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...