Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attributes


Guest

Recommended Posts

Hello every one

 

In my product page i have a option box which will show the options.

But if there is no option a text like none appear

here is my code i dont know what am i doing wrong

 

?  <?php

? ? $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) {

?>

? ? ? ? ? <table border="0" cellspacing="0" cellpadding="2">

<tr><td>NONE</td></tr>

        } else {

? ? ? ? ? <?php

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

? ? ? ? }

 

?>

? ? ? ? ? ? <tr>

? ? ? ? ? ? ? <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

? ? ? ? ? ? ? <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>

? ? ? ? ? ? </tr>

<?php

? ? ? }

?>

? ? ? ? ? </table>

<?php

? ? }

?>

all i did was change if ($products_attributes['total'] > 0) {

to < 0 and add else but it didnt work

 

Can any one help Please

Link to comment
Share on other sites

hamed,

 

Take the "<?php" that you have after the "} else {" and move it before. Like so:

 

<?php
   $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) {
?>
         <table border="0" cellspacing="0" cellpadding="2">
<tr><td>NONE</td></tr> 
<?php
       } else {
     $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");

 

ed

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...