Dominator69 Posted September 28, 2011 Posted September 28, 2011 ver.osc 2.3.1 original $new_prods_content = '<table border="0" width="100%" cellspacing="0" cellpadding="2">'; while ($new_products = tep_db_fetch_array($new_products_query)) { $counter++; if ($col === 0) { $new_prods_content .= '<tr>'; } $new_prods_content .= '<td width="50%" align="center" valign="top" class=" ui-corner-all" bgcolor="#FFFFFF"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br />' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</td>'; $col ++; if (($col > 1) || ($counter == $num_new_products)) { $new_prods_content .= '</tr>'; $col = 0; } } $new_prods_content .= '</table>'; modified $new_prods_content = '<table border="1" width="100%" cellspacing="5" cellpadding="10">'; while ($new_products = tep_db_fetch_array($new_products_query)) { $counter++; if ($col === 0) { $new_prods_content .= '<tr>'; } $new_prods_content .= ' <table class=" ui-corner-all" bgcolor="#FFFFFF" width="50%" cellspacing="5" cellpadding="10"><td align="left" valign="top" ><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td><td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a> <br />' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])). '<br>' . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products['products_id'])) . '</td><p>'; $col ++; if (($col > 1) || ($counter == $num_new_products)) { $new_prods_content .= '</tr>'; $col = 0; } } $new_prods_content .= '</table>'; now modified products are one under another products and i want it 2 in the column thanks in advance
tomcat4x Posted September 29, 2011 Posted September 29, 2011 Your code seems not to be very propper. you can delete <table class=" ui-corner-all" bgcolor="#FFFFFF" width="50%" cellspacing="5" cellpadding="10"> in $new_prods_content there you open a new table and never close it and delete the <p> at the end. There is no <p> in tables between </td> and <td> or </td> and </tr> Then you have to check for the second product in a column. I think the best way is to use $a % $b (Modulus - Remainder of $a divided by $b.). So try $counter % 2. If the remainer is zero you can close the row and open the next row-> </tr><tr> If not go to the top of the while loop for writing the next product in a <td> But you must have a look how many products are left to show. If there is just one left you have to insert a empty <td></td> So you see its a little bit tricky and not so easy to declare out of the mind.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.