0

I must be missing something obvious. Looking to have an if statement where it will only echo the image if BOTH conditions are met. Currently, it is echoing when only one is met

    if ($row['PROT_A']="Y" and $row['CFHL_A']="$G2")
    {
    echo "<img src='/fantasy/images/current.png' width='12' height='12'>";
    }
4
Contributors
7
Replies
46
Views
4 Months
Discussion Span
Last Post by diafol
0

Try this....

if ($row['PROT_A']="Y" && $row['CFHL_A']="$G2")
{
echo "<img src='/fantasy/images/current.png' width='12' height='12'>";
}
0

Thanks PatK - the query yields 11 results as it should. I would expect only one to echo the image - yet all 11 do.

Thanks Diafol - I have tried it both with or without and simply entering the variable result and none yield the result I am looking for.

Still looking...

2

The simple reason is that this is an assignment not a comparison, use...

if ($row['PROT_A']=="Y" && $row['CFHL_A']=="$G2")
{
echo "<img src='/fantasy/images/current.png' width='12' height='12'>";
}
2

Thanks diafol - making progress.

Earlier in the code, $G2 is set to BULL

$G2="BULL";

When I use your suggestion without the variable, it works properly.

     if ($row['PROT_A']=="Y" && $row['CFHL_A']=='BULL')
     {
         echo "<img src='/fantasy/images/current.png' width='12' height='12'>";
         }

However, this does not work...

    if ($row['PROT_A']=="Y" && $row['CFHL_A']=="$G2")
    {
    echo "<img src='/fantasy/images/current.png' width='12' height='12'>";
    }

Clearly, it is how I am defining the Variable $G2. Any help would be appreciated.

Votes + Comments
Don't put $G2 in quotes
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.