Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New Attribute Manager v4b


patator

Recommended Posts

Hello

 

I'm kind of dummy with php and I try to make relationships between attributes.

 

I added 2 boolean fields to the Products_Attribute table : "RIGHT_HAND", "LEFT_HAND"

 

 

To the "new_attribute_include" file, I added two check boxes to indicate, for a selected attribute, if it is available for RIGHT_HAND and/or LEFT_HAND :

 

if ($attribute_RH == "-1") {                       
     echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_RH[]\" value=\"" .$attribute_RH . "\"" . $CHECKED . ">  </TD>";
     }else {
     echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_RH[]\" value=\"" . $attribute_RH . "\">  </TD>";
     }


     if ($attribute_LH == "-1") {                       
     echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_LH[]\" value=\"" . $attribute_LH . "\"" . $CHECKED . ">  </TD>";
     }else {
     echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_LH[]\" value=\"" . $attribute_LH . "\">  </TD>";
     }

 

When I edit (from the admin edition option) a product with Righ_Hand set to "-1" (entered manually in the table), I can see it is correctly ticked next to the related attribute (ie : loft of 15?)

 

Now comes my problem, if I tick RH or LH boxes and click on save, it doesn't save my selection. I'm sure it has sthg to do with the $HTTP_POST_VARS in the new_attribute_change.php, here is what I added to the file :

 $value_RH = $HTTP_POST_VARS[$optionValues[$i] . '_optionValues_RH'];
$value_LH = $HTTP_POST_VARS[$optionValues[$i] . '_optionValues_LH'];
.....
       MYSQL_QUERY( "INSERT INTO products_attributes ( products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order,RH,LH)
                    VALUES( '$current_product_id', '$optionsID', '$optionValues[$i]', '$value_price', '$value_prefix', '$value_sort','$value_RH','$value_LH')" ) or die(mysql_error());
.......

 

I'm sure I'm missing shtg, because I don't really know how works a checkbox in php.

 

I really, really hope a proper developper could have a look at my post and try to help me.

Thanks

Patrice :(

Link to comment
Share on other sites

Sorry but I'm really stuck.

Could a developper read this post and tell me quickly how to get the $HTTP_POST_VARS correct ?

 

Thanks a lot

Pat

 

Hello

 

I'm kind of dummy with php and I try to make relationships between attributes.

 

I added 2 boolean fields to the Products_Attribute table : "RIGHT_HAND", "LEFT_HAND"

To the "new_attribute_include" file, I added two check boxes to indicate, for a selected attribute, if it is available for RIGHT_HAND and/or LEFT_HAND :

 

if ($attribute_RH == "-1") { ? ? ? ? ? ? ? ? ? ? ? 
? ? ?echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_RH[]\" value=\"" .$attribute_RH . "\"" . $CHECKED . ">  </TD>";
? ? ?}else {
? ? ?echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_RH[]\" value=\"" . $attribute_RH . "\">  </TD>";
? ? ?}
? ? ?if ($attribute_LH == "-1") { ? ? ? ? ? ? ? ? ? ? ? 
? ? ?echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_LH[]\" value=\"" . $attribute_LH . "\"" . $CHECKED . ">  </TD>";
? ? ?}else {
? ? ?echo "<TD class=\"main\" align=\"left\"><input type=\"checkbox\" name=\"" . $current_value_id . "_optionValues_LH[]\" value=\"" . $attribute_LH . "\">  </TD>";
? ? ?}

 

When I edit (from the admin edition option) a product with Righ_Hand set to "-1" (entered manually in the table), I can see it is correctly ticked next to the related attribute (ie : loft of 15?)

 

Now comes my problem, if I tick RH or LH boxes and click on save, it doesn't save my selection. I'm sure it has sthg to do with the $HTTP_POST_VARS in the new_attribute_change.php, here is what I added to the file :

 $value_RH = $HTTP_POST_VARS[$optionValues[$i] . '_optionValues_RH'];
$value_LH = $HTTP_POST_VARS[$optionValues[$i] . '_optionValues_LH'];
.....
? ? ? ?MYSQL_QUERY( "INSERT INTO products_attributes ( products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order,RH,LH)
? ? ? ? ? ? ? ? ? ? VALUES( '$current_product_id', '$optionsID', '$optionValues[$i]', '$value_price', '$value_prefix', '$value_sort','$value_RH','$value_LH')" ) or die(mysql_error());
.......

 

I'm sure I'm missing shtg, because I don't really know how works a checkbox in php.

 

I really, really hope a proper developper could have a look at my post and try to help me.

Thanks

Patrice :(

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...