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'>";
    }

Try this....

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

Is that supposed to be a variable? Why in quotes?

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...

Member Avatar
diafol

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'>";
}

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.

commented: Don't put $G2 in quotes +5
Member Avatar
diafol

As scrappedcola says