Re: [PHP-DB] Help with If else if

2012-03-18 Thread Tamara Temple

On Tue, 13 Mar 2012 17:33:43 +0530, Gu®u nagendra802...@gmail.com sent:

Hi,

Please help me with this code. I have 2 different fields in mysql table.
What I want is if the field is empty don't show the image. Please look at
the code below.


?php


  if($search-plugin-ListViewValue()==)
  {

   echo 'a href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';
  }
  if($search-facebook-ListViewValue()==)
  {

  echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';
  }


  else if($search-plugin-ListViewValue()== 
$search-facebook-ListViewValue()==)
{

echo ;
}

else
  {

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

  }


  ?


--
*Best,
*
*Gu®u*



I think we really need to see a lot more than this before we can help.  
What is the output that is generated? What is $search and how is it  
set prior to entering this bit of code? As it stands, I can see no  
reference to MySQL tables in this, nor any idea what values you're  
expecting and not seeing. If you don't already, please set  
error_reporting to the most detailed, and turn on display_errors in  
your output. Before each of the if's echo a var_dump of the values  
you're testing so we can see their exact values.




--
Tamara Temple
   aka tamouse__

May you never see a stranger's face in the mirror


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Help with If else if

2012-03-18 Thread Tamara Temple

On Tue, 13 Mar 2012 21:23:57 +0530, Gu®u nagendra802...@gmail.com sent:


No Michael, your code is also not working. What you have understood is
correct. let me explain it to others too.

If variable twitter and facebook are empty don't echo anything,

if variable twitter has a value and facebook is empty echo out only twitter,

if variable twitter has no value and facebook has a value echo out facebook
only,

and finally if both has values echo out both.

Basically I want to echo out only if there is some value in the database.
But in my case both the images are echoing out.


For probably the bazillionth time, PUT REPLIES ON THE BOTTOM






On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote:


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
} 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 tijn...@gmail.com wrote:


On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com 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

---





--
*Best,
*
*Gu®u*



Recapitulating your pseudocode above, you don't need anything so complex:

if twitter is set:
   emit twitter image
if facebook is set:
   emit facebook image

The two seem completely independent of each other. Thus:

?php
$twitter = $search-plugin-ListViewValue();
if (!empty($twitter)) {
   echo 'a href='.$twitter.'img src=images/twitter.gif  
width=22 height=23//a';

}
$fb = $search-facebook-ListViewValue();
if (!empty($fb)) {
   echo 'a href='.$fb.'img src=images/facebook.gif width=22  
height=23//a';

}
?

The above will give a twitter image+link if the twitter link is set,  
and a facebook image+link if facebook is set. You don't need to do  
anything special if both are set, or if neither is set, as they are  
completely independent of each other.


--
Tamara Temple
   aka tamouse__

May you never see a stranger's face in the mirror


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 1:03 PM, Gu®u nagendra802...@gmail.com wrote:
 Hi,

 Please help me with this code. I have 2 different fields in mysql table.
 What I want is if the field is empty don't show the image. Please look at
 the code below.

I have looked at it.

Maybe you should tell what is wrong, what it outputs currently, and
what it should output. Or perhaps, which errors you get if any?

- Matijn

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
The issue is both the images are echoing and no if else statement is
working.

On Tue, Mar 13, 2012 at 7:22 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 1:03 PM, Gu®u nagendra802...@gmail.com wrote:
  Hi,
 
  Please help me with this code. I have 2 different fields in mysql table.
  What I want is if the field is empty don't show the image. Please look at
  the code below.

 I have looked at it.

 Maybe you should tell what is wrong, what it outputs currently, and
 what it should output. Or perhaps, which errors you get if any?

 - Matijn




-- 
*Best,
*
*Gu®u*


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com 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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Michael Stowe
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 tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com 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

---


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
No Michael, your code is also not working. What you have understood is
correct. let me explain it to others too.

If variable twitter and facebook are empty don't echo anything,

if variable twitter has a value and facebook is empty echo out only twitter,

if variable twitter has no value and facebook has a value echo out facebook
only,

and finally if both has values echo out both.

Basically I want to echo out only if there is some value in the database.
But in my case both the images are echoing out.




On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote:

 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 tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com 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

 ---




-- 
*Best,
*
*Gu®u*


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Michael Stowe
Hmm, what happens with the code I sent you?  Just tested it on my end and
worked exactly as expected.

Try doing a
var_dump($search-plugin-ListViewValue(), $search-facebook-ListViewValue());
to make sure the data being returned is what's expected... you should be
getting string(0)  returned for both.

Thanks,
Mike



On Tue, Mar 13, 2012 at 10:53 AM, Gu®u nagendra802...@gmail.com wrote:

 No Michael, your code is also not working. What you have understood is
 correct. let me explain it to others too.

 If variable twitter and facebook are empty don't echo anything,

 if variable twitter has a value and facebook is empty echo out only
 twitter,

 if variable twitter has no value and facebook has a value echo out
 facebook only,

 and finally if both has values echo out both.

 Basically I want to echo out only if there is some value in the database.
 But in my case both the images are echoing out.




 On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote:

 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 tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com 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

 ---




 --
 *Best,
 *
 *Gu®u*




-- 
---

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

---


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 4:53 PM, Gu®u nagendra802...@gmail.com wrote:
 No Michael, your code is also not working. What you have understood is
 correct. let me explain it to others too.

 If variable twitter and facebook are empty don't echo anything,

 if variable twitter has a value and facebook is empty echo out only twitter,

 if variable twitter has no value and facebook has a value echo out facebook
 only,

 and finally if both has values echo out both.

 Basically I want to echo out only if there is some value in the database.
 But in my case both the images are echoing out.


That's exactly what my code does too, except it's a bit simpler. If
mine isn't working too, then your input is probably different, try a
var_dump on the ListViewValue() items.

- Matijn

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
I tried the below code too considering may be the localhost is really dumb
and we need to tell each and every condition. But still its not working  :(


$tweet = $search-plugin-ListViewValue();
 $fb = $search-facebook-ListViewValue();


 if($tweet==  $fb==)
 {

echo ;

 }
 elseif($fb==  $tweet!=)
 {

 echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';


 }

 elseif($tweet==  $fb!=)
 {


 echo 'a
href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';

 }

 elseif($fb!=  $tweet!=)
 {


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

 }



On Tue, Mar 13, 2012 at 9:44 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 4:53 PM, Gu®u nagendra802...@gmail.com wrote:
  No Michael, your code is also not working. What you have understood is
  correct. let me explain it to others too.
 
  If variable twitter and facebook are empty don't echo anything,
 
  if variable twitter has a value and facebook is empty echo out only
 twitter,
 
  if variable twitter has no value and facebook has a value echo out
 facebook
  only,
 
  and finally if both has values echo out both.
 
  Basically I want to echo out only if there is some value in the database.
  But in my case both the images are echoing out.
 

 That's exactly what my code does too, except it's a bit simpler. If
 mine isn't working too, then your input is probably different, try a
 var_dump on the ListViewValue() items.

 - Matijn




-- 
*Best,
*
*Gu®u*