Guest Posted December 10, 2004 Share Posted December 10, 2004 Thanks for checking my post. Please help me wrap this module into a text table before I pull what's left of my hair out :blink: What I need: Does anyone have an also purchased module that resembles this? I have it close, but I can't get it to wrap (one line each product) Here's the code for what I have so far. (this image and code below)... What I have now: [/code]<?php /* $Id: also_purchased_products.php,v 1.21 2003/02/12 23:55:58 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ if (isset($HTTP_GET_VARS['products_id'])) { $orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED); $num_products_ordered = tep_db_num_rows($orders_query); if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED) { ?> <!-- also_purchased_products //--> <?php $row = 0; $col = 0; $info_box_contents = array(); while ($orders = tep_db_fetch_array($orders_query)) { $orders['products_name'] = tep_get_products_name($orders['products_id']); $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="shopx" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $orders['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $orders['products_image'], $orders['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $orders['products_id']) . '">' . $orders['products_name'] . '</a>'); $col ++; if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); ?> <!-- also_purchased_products_eof //--> <?php } } ?> Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2004 Share Posted December 10, 2004 Try this: <?php /* $Id: also_purchased_products.php,v 1.21 2003/02/12 23:55:58 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright ? 2003 osCommerce Released under the GNU General Public License */ if (isset($HTTP_GET_VARS['products_id'])) { $orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED); $num_products_ordered = tep_db_num_rows($orders_query); if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED) { ?> <!-- also_purchased_products //--> <?php $info_box_contents = array(); while ($orders = tep_db_fetch_array($orders_query)) { $orders['products_name'] = tep_get_products_name($orders['products_id']); $info_box_contents[] = array('align' => 'left', 'params' => 'class="shopx" width="100%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $orders['products_id']) . '">' . $orders['products_name'] . '</a>'); } new contentBox($info_box_contents); ?> <!-- also_purchased_products_eof //--> <?php } } ?> I removed the call to the image as well... Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted December 10, 2004 Share Posted December 10, 2004 so, you just want 1 column ? remove $col ++; if ($col > 2) { $col = 0; $row ++; } and just keep $row ++; KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2004 Share Posted December 10, 2004 You guys rock Thanks., will get it posted. TJ 1 column. :) so, you just want 1 column ? remove $col ++; if ($col > 2) { $col = 0; $row ++; } and just keep $row ++; <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2004 Share Posted December 10, 2004 Figured I better place the also purchased module code I ended up using on the forum. Thanks again guys. Saved me a ton of time.... <HR color="white" size="1" width="200"><table width="365" border="0" bordercolor="white"cellpadding="1" cellspacing="0"> <tr> <td class="shopx" bgcolor="cccccc"><font class="shopx"><b> Customers who bought this also bought:</b> </font><BR> <table border="0" bgcolor="cccccc" bordercolor="white" cellpadding="0" cellspacing="0" width="365"> <tr> <td> <?php /* $Id: also_purchased_products.php,v 1.21 2003/02/12 23:55:58 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ if (isset($HTTP_GET_VARS['products_id'])) { $orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED); $num_products_ordered = tep_db_num_rows($orders_query); if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED) { ?> <!-- also_purchased_products //--> <?php $row = 0; $col = 0; $info_box_contents = array(); while ($orders = tep_db_fetch_array($orders_query)) { $orders['products_name'] = tep_get_products_name($orders['products_id']); $info_box_contents[$row][$col] = array('align' => 'left', 'params' => 'class="shopx" border="0" width="33%" valign="top"', 'text' => '»» <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $orders['products_id']) . '">' . $orders['products_name'] . '</a><!-- <BR><img src=images/pixel.gif width=200 height=1 vspace=0> -->'); $row ++; } new contentBox($info_box_contents); ?> <!-- also_purchased_products_eof //--> <?php } } ?></td> </tr> </table> </td> </tr> </table> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.