I have a PHP-based shopping cart, and an auto-feed generator that allows me to insert PHP code to solve for custom fields that it uses in generating feeds for comparison shopping sites.

I am not a PHP programmer, and so I'm having trouble with what is a very simple piece of code. I took the following code (which DOES work):

if ($data['free_shipping'] == 'Y') {
$field_value = 'Free Shipping!';
} else {
$field_value = 'Fast Reliable Shipping';
}

And modified it as follows (this one does NOT work):

if ($data['league'] == 'NFL') {
$field_value = 'Football';
} else {
$field_value = 'Baseball';
}

What am I doing wrong? The code above returns 'Baseball' every time.

Can anyone help?

Thanks!!!!

    Echo $data['league'] and see what it comes back with, if it's NFL then I have no idea if it doesn't then there is your problem.

      Basically if $data['leaque'] contains anything besides 'NFL' you are going to get baseball. Given the code you've shown us, we have no idea where $data is coming from so it's impossible to say much else about it.

        Write a Reply...