Jump to content

Why dos this loop not split up after 15 options?


avu

Recommended Posts

Why dos this loop not split up after 15 options?

 

$count      = 0;
$maxPerList = 15;

echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

echo "<ul>";
foreach($products_options_name as $currValue) {
if($count == $maxPerList) {
echo "</ul>";
echo "<ul>";
$count = 0;
}   
echo "</li>";      
$count++;
echo "</ul>";

all the file

<?php
/*
  $Id$
  adapted for Separate Pricing Per Customer v4.2 2007/06/23

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

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

  $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
  $product_check = tep_db_fetch_array($product_check_query);
// BOF Separate Pricing per Customer
  if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
    $customer_group_id = $_SESSION['sppc_customer_group_id'];
  } else {
    $customer_group_id = '0';
  }
// EOF Separate Pricing per Customer

  require(DIR_WS_INCLUDES . 'template_top.php');

  if ($product_check['total'] < 1) {
?>

<div class="contentContainer">
  <div class="contentText">
    <?php echo TEXT_PRODUCT_NOT_FOUND; ?>
  </div>

  <div style="float: right;">
    <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?>
  </div>
</div>

<?php
  } else {
    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product_info = tep_db_fetch_array($product_info_query);

    tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

    if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
// BOF Separate Pricing per Customer
      if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
        $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
        if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
          $product_info['products_price']= $scustomer_group_price['customers_group_price'];
      }
      } // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer
      $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
    } else {
// BOF Separate Pricing per Customer
      if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
        $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
        if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
				$product_info['products_price']= $scustomer_group_price['customers_group_price'];
			}
		} // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer
      $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
    }

    if (tep_not_null($product_info['products_model'])) {
      $products_name = $product_info['products_name'] . '<br /><span class="smallText">[' . $product_info['products_model'] . ']</span>';
    } else {
      $products_name = $product_info['products_name'];
    }
?>

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>

<div>
  <style="float: right;"><?php echo $products_price; ?>
  <h1><?php echo $products_name; ?></h1>
</div>

<div class="contentContainer">
  <div class="contentText">

<?php
    if (tep_not_null($product_info['products_image'])) {
      $pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");

      if (tep_db_num_rows($pi_query) > 0) {
?>

    <div id="piGal" style="float: right;">
      <ul>

<?php
        $pi_counter = 0;
        while ($pi = tep_db_fetch_array($pi_query)) {
          $pi_counter++;

          $pi_entry = '        <li><a href="';

          if (tep_not_null($pi['htmlcontent'])) {
            $pi_entry .= '#piGalimg_' . $pi_counter;
          } else {
            $pi_entry .= tep_href_link(DIR_WS_IMAGES . $pi['image']);
          }

          $pi_entry .= '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $pi['image']) . '</a>';

          if (tep_not_null($pi['htmlcontent'])) {
            $pi_entry .= '<div style="display: none;"><div id="piGalimg_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div></div>';
          }

          $pi_entry .= '</li>';

          echo $pi_entry;
        }
?>

      </ul>
    </div>

<script type="text/javascript">
$('#piGal ul').bxGallery({
  maxwidth: 300,
  maxheight: 200,
  thumbwidth: <?php echo (($pi_counter > 1) ? '75' : '0'); ?>,
  thumbcontainer: 300,
  load_image: 'ext/jquery/bxGallery/spinner.gif'
});
</script>

<?php
      } else {
?>

    <div id="piGal" style="float: right;">
      <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), null, null, 'hspace="5" vspace="5"') . '</a>'; ?>
    </div>

<?php
      }
?>

<script type="text/javascript">
$("#piGal a[rel^='fancybox']").fancybox({
  cyclic: true
});
</script>

<?php
    }
?>

<?php echo stripslashes($product_info['products_description']); ?>

<?php
// BOF SPPC Hide attributes from customer groups
    $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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");
    $products_attributes = tep_db_fetch_array($products_attributes_query);
    if ($products_attributes['total'] > 0) {
?>

    <p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>

    <p>
<!--
            // Code segment includes/modified for Multiple product option lines.
    // maintainance and Qns : Harishyam :> feenix_666@yahoo.com
-->
<?php	     
       if ($products_options_total['total'] == 1) {
		for($i=0;$i<$products_attributes['total'];$i++)
		{
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 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, pa.options_values_price, pa.price_prefix, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
			$list_of_prdcts_attributes_id = '';
			$products_options = array(); // makes sure this array is empty again
        while ($_products_options = tep_db_fetch_array($products_options_query)) {
				$products_options[] = $_products_options;
				$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
			}

			if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
				 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
				 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
				 while ($pag_array = tep_db_fetch_array($pag_query)) {
					 $cg_attr_prices[] = $pag_array;
				 }

				 // substitute options_values_price and prefix for those for the customer group (if available)
				 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
					 for ($n = 0 ; $n < count($products_options); $n++) {
						 for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
							 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
									$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
									$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
							 }
						 } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
					 }
				 } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
			 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

			 for ($n = 0 ; $n < count($products_options); $n++) {
					$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
					if ($products_options[$n]['options_values_price'] != '0') {
						$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
					}
				}
// EOF SPPC attributes mod

        if (is_string($HTTP_GET_VARS['products_id']) && 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;
	  }	
?>
	      
	        
<?php         	   
$count      = 0;
$maxPerList = 15;

echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

echo "<ul>";
foreach($products_options_name as $currValue) {
if($count == $maxPerList) {
echo "</ul>";
echo "<ul>";
$count = 0;
}   
echo "</li>";      
$count++;
echo "</ul>";

  }} } // End of loop

    } else {
    //do your regular thing
    

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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, 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 . "'");
        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']);
          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;
        }
	}        
?>
      <strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br />
<?php
      }
?>
    </p>

<?php
    }
?>

    <div style="clear: both;"></div>

<?php
    if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>

    <p style="text-align: center;"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></p>

<?php
    }	    
?>

  </div>

<?php
    $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and reviews_status = 1");
    $reviews = tep_db_fetch_array($reviews_query);
?>

  <div class="buttonSet">
    <span class="buttonAction"><?php if ($products_options_total['total'] != 1) { echo 'Enter Quantity: ' . tep_draw_input_field('cart_quantity','1','size="3" style="text-align:right;"') . ' ' ; } ?>
<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>
</div>

<?php
    if ((USE_CACHE == 'true') && empty($SID)) {
      echo tep_cache_also_purchased(3600);
    } else {
      include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
    }
?>

</div>

</form>

<?php
  }

  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Link to comment
Share on other sites

For one, the example you posted contains two opening { and only one closing }. It also contains a closing </li> echo, but not an opening one. It is also badly formatted. I know you've tabulated things properly in your 'all the file' post, but most will not go through the entire file looking for what's going wrong.

 

Posting accurate examples is paramount to getting a solution.

 

I've corrected the errors in your above example, and after filling $products_options_name with dummy values I've found your script works as intended.

 

Programming is all about accuracy, consistency and logic. Try writing out what you've programmed in pseudocode if you have issues finding small mistakes such as the ones listed above.

Link to comment
Share on other sites

Not sure where you want to place the <li> but I think this is the place.

sorry for the missing }

It dos not split up anything as intended yet.

I think the problem is within this code

<?php	     
       if ($products_options_total['total'] == 1) {
		for($i=0;$i<$products_attributes['total'];$i++)
		{
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 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, pa.options_values_price, pa.price_prefix, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
			$list_of_prdcts_attributes_id = '';
			$products_options = array(); // makes sure this array is empty again
        while ($_products_options = tep_db_fetch_array($products_options_query)) {
				$products_options[] = $_products_options;
				$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
			}

			if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
				 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
				 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
				 while ($pag_array = tep_db_fetch_array($pag_query)) {
					 $cg_attr_prices[] = $pag_array;
				 }

				 // substitute options_values_price and prefix for those for the customer group (if available)
				 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
					 for ($n = 0 ; $n < count($products_options); $n++) {
						 for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
							 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
									$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
									$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
							 }
						 } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
					 }
				 } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
			 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

			 for ($n = 0 ; $n < count($products_options); $n++) {
					$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
					if ($products_options[$n]['options_values_price'] != '0') {
						$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
					}
				}
// EOF SPPC attributes mod

        if (is_string($HTTP_GET_VARS['products_id']) && 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;
	  }	
?>
	      
	        
<?php         	   
$count      = 0;
$maxPerList = 15;

echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

echo "<ul>";

foreach($products_options_name as $currValue) {
if($count == $maxPerList) {
echo "</ul>";
echo "<ul>";

$count = 0;
} 
echo "<li>";  
echo "</li>";      
$count++;
echo "</ul>";

  }} } // End of loop

    } 

Link to comment
Share on other sites

Again, an incomplete, badly formatted example.

 

Again, I corrected the mistakes I mentioned in your first example, actually outputted the array you're looping through, and everything worked fine.

 

I'm done helping until you can show me you want to apply my advice, and not just be given a solution.

Link to comment
Share on other sites

Hi Xyph

 

not sure what you mean, is it this?

<?php	     
       if ($products_options_total['total'] == 1) {
		for($i=0;$i<$products_attributes['total'];$i++)
		{
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 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, pa.options_values_price, pa.price_prefix, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
			$list_of_prdcts_attributes_id = '';
			$products_options = array(); // makes sure this array is empty again
        while ($_products_options = tep_db_fetch_array($products_options_query)) {
				$products_options[] = $_products_options;
				$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
			}

			if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
				 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
				 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
				 while ($pag_array = tep_db_fetch_array($pag_query)) {
					 $cg_attr_prices[] = $pag_array;
				 }

				 // substitute options_values_price and prefix for those for the customer group (if available)
				 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
					 for ($n = 0 ; $n < count($products_options); $n++) {
						 for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
							 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
									$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
									$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
							 }
						 } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
					 }
				 } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
			 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

			 for ($n = 0 ; $n < count($products_options); $n++) {
					$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
					if ($products_options[$n]['options_values_price'] != '0') {
						$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
					}
				}
// EOF SPPC attributes mod

        if (is_string($HTTP_GET_VARS['products_id']) && 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;
	  }	
?>
	      
	        
<?php         	   
$count      = 0;
$maxPerList = 15;

echo '<ul><li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

echo "<ul>";

foreach($products_options_name as $currValue) {
if($count == $maxPerList) {
echo "</ul>";
echo "<ul>";
echo "<li>"; 
$count = 0;
} 

echo "</li>";      
$count++;
echo "</ul>";

  }} } // End of loop

    } 

Link to comment
Share on other sites

Sins my PHP/HTML knowledge are limit as well as my English are limit please explain in other words what you want I do so it is not incomplete, badly formatted example.

When you said “badly formatted” I think you mean <ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "> has to be in the CSS, let me know if I misunderstand? Because that is changed

And when you sad “incomplete” you means the missing {} but there are the same numbers

 

Link to comment
Share on other sites

Badly formatted

<?php 

if( condition ) {
a bunch of code
that isn't tabulated
if( another condition ) {
gets really hard
to follow
and it becomes really
easy to forget to close
conditional statments
}
}

?>

 

Well formatted

<?php 

if( condition ) {
a bunch of code
that isn't tabulated
if( another condition ) {
	gets really hard
	to follow
	and it becomes really
	easy to forget to close
	conditional statments
}
}

?>

 

Incomplete means it won't run on it's own. I have to fix the code for it to even run. When you echo '</li>'; without echo '<li>'; anywhere else in the script, you are trying to close a tag that hasn't been opened.

Link to comment
Share on other sites

Ok I got the formatting I think and hope.

The tags ul and li now open and close.

 

<?php	     
       if ($products_options_total['total'] == 1) {
		for($i=0;$i<$products_attributes['total'];$i++)
		{
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 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, pa.options_values_price, pa.price_prefix, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
			$list_of_prdcts_attributes_id = '';
			$products_options = array(); // makes sure this array is empty again
        while ($_products_options = tep_db_fetch_array($products_options_query)) {
				$products_options[] = $_products_options;
				$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
			}

			if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
				 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
				 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
				 while ($pag_array = tep_db_fetch_array($pag_query)) {
					 $cg_attr_prices[] = $pag_array;
				 }

				 // substitute options_values_price and prefix for those for the customer group (if available)
				 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
					 for ($n = 0 ; $n < count($products_options); $n++) {
						 for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
							 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
									$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
									$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
							 }
						 } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
					 }
				 } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
			 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

			 for ($n = 0 ; $n < count($products_options); $n++) {
					$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
					if ($products_options[$n]['options_values_price'] != '0') {
						$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
					}
				}
// EOF SPPC attributes mod

        if (is_string($HTTP_GET_VARS['products_id']) && 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;
	  }	
?>
	      
	        
<?php         	   
            $count      = 0;
            $maxPerList = 15;

            echo '<ul><li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
            echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

            echo "</li></ul>";

                    foreach($products_options_name as $currValue) {
                             if($count == $maxPerList) {
                            
                             echo "<ul>";
                             echo "<li>"; 
                             
                      
                             $count = 0;    
                                   
                             echo "</li>";                            
                             $count++; 
                             echo "</ul>";
                             }                              
                   }
  } } 

Link to comment
Share on other sites

$count = 0;    
                                   
echo "</li>";                            
$count++; 

 

I feel like the $count=0; then $count++  is pointless :S

 

$count = 0;

$count = 1;

$count = 0;

$count = 1;

 

 

Edit : Nevermind, you changed your code from the first post and it is even more derranged now.

 

Link to comment
Share on other sites

So this must be this part

Now with out $count = 0;

Can’t figure out if the $count++; has to be before, after or between the <ul><li>

 

echo '<ul><li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
            echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

            echo "</li></ul>";

                    foreach($products_options_name as $currValue) {
                             if($count == $maxPerList) {
                            
                             echo "<ul>";
                             echo "<li>"; 
                             
                      
                              $count++;   
                                   
                             echo "</li>";                            
                            
                             echo "</ul>";
                             }                              
                   }

Link to comment
Share on other sites

Still not 100% sure what you are trying to do but what about something like ...

 

 

$total = count($products_options_name);
$count = 1;
echo "<ul>";
foreach($products_options_name as $currValue) {
echo "<li>{$currValue}</li>";
if ($count % $maxPerList == 0 && $count != $total) {  //Check if remainder is 0 or if it is the last product
	echo "</ul><ul>";
}
$count++;
}
echo "</ul>";

Link to comment
Share on other sites

What I want to do is show products_options 1-15 than split the listing so row 16-30 come in new column split again and show the next 15 products_options

 

This code list in 3 line per product and do also not cut after 15.

$count      = 0;
            $maxPerList = 15;

            echo '<ul><li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
            echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

            echo "</li></ul>";
            $total = count($products_options_name);
            $count = 1;
		echo "<ul>";
		    foreach($products_options_name as $currValue) {
		    echo "<li>{$currValue}</li>";
		        if ($count % $maxPerList == 0 && $count != $total) {  //Check if remainder is 0 or if it is the last product
		        echo "</ul><ul>";    
                  } 
		    $count++;    
		} 
	echo "</ul>";
		       
  } } 

Link to comment
Share on other sites

The $products_options_name is a color

For each color are the name and a text felt to put quantity.

 

I don’t get errors but the option name are now 2 line down from the text input felt and the line between there is a number “1” and it must be on same line

 

 

Link to comment
Share on other sites

This is the out put

<ul><li><input type="text" name=0_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="0_id[1]" value="1" />01 Red</li></ul><ul><li>1</li><li>Color</li></ul>		      
	        
<ul><li><input type="text" name=1_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="1_id[1]" value="2" />02 Orange Yellow</li></ul><ul><li>1</li><li>Color</li></ul>		      
	        
<ul><li><input type="text" name=2_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="2_id[1]" value="3" />03 Orange</li></ul><ul><li>1</li><li>Color</li></ul>	

Link to comment
Share on other sites

You got me thinking

Actually I think that the $products_options_name is the option group and not the options.

So with $products_attributes the new out put count all the option that in this case is 26

<?php	     
       if ($products_options_total['total'] == 1) {
		for($i=0;$i<$products_attributes['total'];$i++)
		{
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 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, pa.options_values_price, pa.price_prefix, pa.products_attributes_id 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 . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
			$list_of_prdcts_attributes_id = '';
			$products_options = array(); // makes sure this array is empty again
        while ($_products_options = tep_db_fetch_array($products_options_query)) {
				$products_options[] = $_products_options;
				$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
			}

			if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
				 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
				 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
				 while ($pag_array = tep_db_fetch_array($pag_query)) {
					 $cg_attr_prices[] = $pag_array;
				 }

				 // substitute options_values_price and prefix for those for the customer group (if available)
				 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
					 for ($n = 0 ; $n < count($products_options); $n++) {
						 for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
							 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
									$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
									$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
							 }
						 } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
					 }
				 } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
			 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

			 for ($n = 0 ; $n < count($products_options); $n++) {
					$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
					if ($products_options[$n]['options_values_price'] != '0') {
						$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
					}
				}
// EOF SPPC attributes mod

        if (is_string($HTTP_GET_VARS['products_id']) && 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;
	  }	
?>
	      
	        
<?php         	   
            $count      = 0;
            $maxPerList = 15;

            echo '<ul><li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;';
            echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];   

            echo "</li></ul>";
            $total = count($products_attributes);
            $count = 1;
		echo "<ul>";
		    foreach($products_attributes as $currValue) {
		    echo "<li>{$currValue}</li>";
		        if ($count % $maxPerList == 0 && $count != $total) {  //Check if remainder is 0 or if it is the last product
		        echo "</ul><ul>";    
                  } 
		    $count++;    
		} 
	echo "</ul>";
		       
  } } // End of loop

    } 

 

the out put now is

<ul><li><input type="text" name=0_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="0_id[1]" value="1" />01 Red</li></ul><ul><li>26</li></ul>		      
	        
<ul><li><input type="text" name=1_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="1_id[1]" value="2" />02 Orange Yellow</li></ul><ul><li>26</li></ul>		      
	        
<ul><li><input type="text" name=2_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="2_id[1]" value="3" />03 Orange</li></ul><ul><li>26</li></ul>		      
	        
<ul><li><input type="text" name=3_quantity value="" style="text-align:right;" size="3">&#8194;<input type="hidden" name="3_id[1]" value="4" />04 Parstel Pink</li></ul><ul><li>26</li></ul>		      

Link to comment
Share on other sites

I’m not sure what exactly you want to know or how to find it?

In the database there are products_options that contains products_options_id, language_id, products_options_name

And

products_options_values that contains products_options_values_id, language_id, products_options_values_name, and this is the ones I like to spilt up after every15

 

Link to comment
Share on other sites

It produces

array

  'total' => string '26' (length=2)

 

 

also in the date base here are There are also products_attributes that contains products_attributes_id, products_id, options_id, options_values_id, options_values_price, price_prefix attributes_hide_from_groups

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.