Re: Help with If else if

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From looking at your code, the issue is that your if statements are
checking for the same criteria as your else statements, meaning that if the
string is empty ("") the if statements will be triggered, and since the if
statements are true, the elseif statement will not be.  Or if the string
isn't empty, neither the if or the elseif statements will be triggered,
causing the else statement to be activated.  Either way, the images would
be printed out. *
*
*
*
*Did you mean to do this?*

<?php
if($search->plugin->ListViewValue() == "" &&
$search->facebook->ListViewValue() == "") {
    // Neither one has a value
} elseif ($search->plugin->ListViewValue() != "" &&
$search->facebook->ListViewValue() != "") {
    // Both have a Value
    echo '<a href="' . $search->plugin->ListViewValue() . '"><img
    src="images/twitter.gif" width="22" height="23"/></a></a>' . '<a
    href="' . $search->facebook->ListViewValue() . '"><img
    src="images/facebook.gif" width="22" height="23"/></a></a>';
} elseif ($search->plugin->ListViewValue() != "") {
    // Twitter has a value
    echo '<a href="' . $search->plugin->ListViewValue() . '"><img
    src="images/twitter.gif" width="22" height="23"/></a></a>';
} else {
    // Facebook has a value (only possible option left)
    echo '<a href="' . $search->facebook->ListViewValue() . '"><img
    src="images/facebook.gif" width="22" height="23"/></a></a>';
}
?>



Hope that helps,
Mike



On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt <tijnema@xxxxxxxxx> wrote:

> On Tue, Mar 13, 2012 at 3:06 PM, Gu®u <nagendra802000@xxxxxxxxx> wrote:
> > The issue is both the images are echoing and no if else statement is
> > working.
> >
>
> First of all, please bottom post on this (and probably any) mailing list.
>
> You should perhaps provide what the contents of
> $search->plugin->ListViewValue()=="" and
> $search->facebook->ListViewValue()=="" is.
> Though, if I understood you correctly, it would be as simple as:
> $facebookEnabled = $search->facebook->ListViewValue()!="";
> $twitterEnabled = $search->plugin->ListViewValue()!="";
> if($facebookEnabled)
>          {
>
>          echo '<a href="'.$search->facebook->ListViewValue().'"><img
> src="images/facebook.gif" width="22" height="23"/></a></a>';
>         }
>          if($twitterEnabled)
>          {
>
>         echo '<a href="'.$search->plugin->ListViewValue().'"><img
> src="images/twitter.gif" width="22" height="23"/></a></a>';
>         }
>
> - Matijn
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
-----------------------

"My command is this: Love each other as I
have loved you."                         John 15:12

-----------------------

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux