Jump to content

End of Table Row Count Issue


bolty2

Recommended Posts

Hi All...

 

Just stumbled on this great forum in my quest to solve my issue so though i would try a post and see if i can get any luck here... :-\

 

Ok, im a bit of a novice at php, i can do the basic stuff but never really touched on trickier stuff so really hoping someone can give me some tips on what i have wrong or write..

 

Ok, my problem is this, i have a page that pulls content with php and this is placed into a table.

Now depending on how much content there is determins how many tables are used down the page..

So what i use is a simple set up that inserts a simple </tr><tr> after each table..

Now the problem is this at the last table its also inserting the </tr><tr> before the table closing tags which messes the page and validation up..

 

I will include a snippit which may explain a bit more whats going on...

 

    $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>';

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>';
$iec='1';

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

</td></tr></table> 


<?php
    }
?>

 

 

As you can see i can control how many rows go across before the </tr><tr> comes in after the table..

 

The problem is the </tr><tr> is being used after the last table..

 

Sorry if this is not clear but im struggling with words to explain this.. as you can see its an oscommerce file

 

Thanks for any tips..

 

Ian

Link to comment
https://forums.phpfreaks.com/topic/191234-end-of-table-row-count-issue/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.