If else not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
robbiev
Forum Newbie
Posts: 1
Joined: Fri Jun 13, 2014 9:40 am

If else not working

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: If else not working

Post 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?
Post Reply