Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Layout advice...


Guest

Recommended Posts

Posted

Hi all..

 

I have a problem and wondered if any of the great coders out there could point me in the right direction.

 

I have a page that is pulling data from queries and putting it in a table structure (usualy oscommece stuff)..

 

Now my issue is this, i can set the numbers of <td> table tags that go across in a row until it break to a new row with... </tr><tr>

 

BUT when it comes to the very last row i dont need this added so it messes up the page and validation..

 

just wondring if there is a solution for this...

 

Ive attached a bit of code and you will see right at the bottom how the $count++ adds the </tr><tr>

 

Been scratching my head all day, tried divs with no success and thought about an php if/else but dont know what to code..

 

Any ideas would be most appeciated..

 

<?php
/*
 $Id: options_images.php,v 1.6.6 2003/08/18 

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_OPTIONS_IMAGES);

   $iec='0';

   $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
     echo '<b><span class="optionsAvailable">' . TEXT_PRODUCT_OPTIONS. '</span></b>';
?>

<?php
     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_images_enabled from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pov.products_options_values_thumbnail, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pov.products_options_values_name asc");

       while($products_options = tep_db_fetch_array($products_options_query)){ 
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name'], 'thumbnail' => $products_options['products_options_values_thumbnail']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }

	if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }

?>
            <table border="0" cellspacing="0" cellpadding="2">
            <tr>
             <td class="main" valign="top"><b><?php echo $products_options_name['products_options_name']. ':'; ?></b>
             <?php 
     		    if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true' && ($products_options_name['products_options_images_enabled'] != 'false')){
                 echo '<br><span class="smallText"><i>  ' . TEXT_SELECT_DESIRED. '<br>  '. TEXT_CLICK_IMAGES. '<br></i></span>'; 
               }
             ?>
             </td>
             </tr>
             </table>

<?php 
             if ($products_options_name['products_options_images_enabled'] == 'false'){
               echo '<table><tr><td class="main"> ' . tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . '</td></tr></table>';
             }else {
               $count=0;
               echo '<table><tr><td class="main"><table><tr>';
               foreach ($products_options_array as $opti_array){
                 echo '<td align="center"><table cellspacing="5" cellpadding="0" border="0"><tr>';
                 if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true'){ 
                   echo '<td align="center"><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_OPTIONS_IMAGES_POPUP, 'oID=' . $opti_array['id']) .'\')">' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail'], $opti_array['text'], OPTIONS_IMAGES_WIDTH, OPTIONS_IMAGES_HEIGHT) . '</a></td></tr>';
                 }else{
                   echo '<td align="center">' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail'], $opti_array['text'], OPTIONS_IMAGES_WIDTH, OPTIONS_IMAGES_HEIGHT) . '</td></tr>';
                 }
                 echo '<tr><td class="main" align="center">' . $opti_array['text'] . '</td></tr>';

//Radio button disable auto check mod Options as Images MS2 v1.5
//This will add a variable to the loop and make the value untrue.
//However if you check a radio button, you still can't uncheck it by clicking it again. 
//In that case you need to change 'radio' to 'checkbox' in the above code. . . 
//this will put a checkbox there which can be unchecked by clicking it again.
//							      echo '<tr><td align="center"><input type="radio" name ="id[' . $products_options_name['products_options_id'] . ']" value="' . $opti_array['id'] . '" checked></td></tr></table></td>';
if ($iec=='1') { $checkedd=''; } else { $checkedd='checked'; }
echo '<tr><td align="center"><input type="radio" name ="id[' . $products_options_name['products_options_id'] . ']" value="' . $opti_array['id'] . '" ' . $checkedd . ' ></td></tr></table></td>';
$iec='1';
//END Radio button disable auto check mod Options as Images MS2 v1.5

										$count++;
                     if ($count%OPTIONS_IMAGES_NUMBER_PER_ROW == 0) {
						 	        echo '</tr><tr>';
							        $count = 0;
									}
									 }
								echo '</tr></table>';
							}
?>

<?php
     }
?>

</tr></table> 


<?php
   }
?>

 

Cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...