Page 1 of 1

If else not working

Posted: Fri Jun 13, 2014 9:58 am
by robbiev
Hi guys i have only been doing php for about 1 year so be gentle with me
I have a auction website which is all working ok except one thing product attribute and its all down to if else command
This page has two commands normal quantity and product attribute quantity
this is the code

Code: Select all

$attributes = attributes_display_to_raw($_POST['product_attributes']);

   $quantity_unlimited = false;
   if ($item_details['enable_product_attributes']) {
      $quantity_output = getQuantity($item_details['auction_id'], $attributes);
      $item_details['quantity'] = $quantity_output;
   }
   else {
	   
      $quantity_output = $item_details['quantity'];
   }
   $template->set('quantity_output', $quantity_output);

the product attribute work ok if there is a product attribute but if there is no attribute the listing is show 0 even if the data base has 10
if i remove

Code: Select all

	$attributes = attributes_display_to_raw($_POST['product_attributes']);

   $quantity_unlimited = false;
   if ($item_details['enable_product_attributes']) {
      $quantity_output = getQuantity($item_details['auction_id'], $attributes);
      $item_details['quantity'] = $quantity_output;


The quantity is fine but the attribute do not work but that because i remove the code

too me it looks like a if else problem but im not experienced enough to say

please help i have been on this for over a week

thank you

Re: If else not working

Posted: Fri Jun 13, 2014 10:04 am
by Celauran
Sorry, but I'm having a little trouble understanding what/where the problem is. If $_POST['product_attributes'] isn't set, then your $attributes variable is wrong, which then makes getQuantity() return the wrong value?