![]() |
quick php question
I suck with php. Don't post unless i spent over an hour trying to figure out a simple equation.
What is the correct way to say this? If the item is part1, part2, or the ebay fees are under 25, sig is 0, otherwise sig is 1. I tried putting the brackets in different spots with no luck, sig keeps being declared as 0 even though the item is for part1 and the ebay fees are over 25. Below is the most recent code I tried. Code:
<?php if ($item->SKU != 'part1' || $item->SKU != 'part2' || $recipient->ebay_fees < '25'){ $sig='0';} else { $sig='1';} print $sig ?> |
!= means not equal right? and == means equal?
I'm not good at PHP either. |
Quote:
php isnt stricly typed but just for purposes of practice if (($item->SKU != 'part1' || $item->SKU != 'part2') || $recipient->ebay_fees < '25'){ $sig='0';} else { $sig='1';} should work |
also actually the other poster is right != is not equal and == is equals so not sure if it was a typo in your explanation or just wrong coding
|
Quote:
if I echo $recipient->ebay_fees it shows a value of 27, thats the way I am pulling it. |
I intentionally put does not equal !=
|
Basically sig should be 1 if any of those 3 criteria are met which 2 of 3 are.
|
Now, I am no PHP expert but maybe it will make more sense, If you say what the criteria is as opposed to what it isn't
If I am hearing your right, it should be completely backwards. if the item is 1 or the item is 2 or the fee < 25 sig 1, is that correct? If so. if (($item->SKU == 'part1' || $item->SKU == 'part2') || $recipient->ebay_fees > '25'){ $sig='1';} else { $sig='0';} |
Have you tried using 'Switch-Case' instead?..
http://php.net/manual/en/control-structures.switch.php Example: PHP Code:
|
PHP Code:
|
Quote:
Thanks for all the suggestions, this one worked in declaring sig as 1 but if sig is not 1 then it does not declare sig as anything, it should be declared as 0 if not 1, i think I can do this myself though :) I did the not equals because sometimes there are multiple items and this was my way of troubleshooting it |
Got it all fixed, thanks again!
|
All times are GMT -7. The time now is 08:49 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123