a.beam.reach Posted April 26, 2007 Share Posted April 26, 2007 I am wondering how to ignore lines of PHP code if the applicable variable is empty. For example in the code below. . . . if the variable $r is empty. . .. I would like the entire line: echo "http://www.mysite.com/images/$r/1" to be ignored. Can you tell that I am very novice!!!! I am learning though. <? // SET GALLERY OPTIONS HERE // ----------------------- // Set Gallery options by editing this text: $q =$_POST['q']; $r =$_POST['r']; echo "http://www.mysite.com/images/$q/1" echo "http://www.mysite.com/images/$r/1" ?> Quote Link to comment Share on other sites More sharing options...
LazyJones Posted April 26, 2007 Share Posted April 26, 2007 $q =$_POST['q']; $r =$_POST['r']; if(!empty($q)) { echo "http://www.mysite.com/images/$q/1"; } if(!empty($r)) { echo "http://www.mysite.com/images/$r/1"; } Quote Link to comment Share on other sites More sharing options...
xenophobia Posted April 26, 2007 Share Posted April 26, 2007 If $_POST['q'] adn $_POST['r'] is a text box then: if(trim($r) != ""){ echo ......; } If the $_POST['r'] is an option button or checkbox then: if(isset($_POST['q'])){ echo .......; } Quote Link to comment Share on other sites More sharing options...
a.beam.reach Posted April 26, 2007 Author Share Posted April 26, 2007 Thank you LazyJones and xenophobia. . .. I did not get a chance to try your suggestion xenophobia. . . . as I had already tried the suggestion of LazyJones. It worked great! I did notice the suggestions were slightly different. Guess there is more than one way to skin a cat! Thanks to you both. Trevor Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.